Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

Commit

Permalink
Merge pull request #634 from Nike-Inc/feat/front-end-ad-group-zoo-1492
Browse files Browse the repository at this point in the history
Front End: Added support for enforcing AD group naming pattern
  • Loading branch information
slichlyter12 authored Sep 3, 2021
2 parents 98ca044 + d4aeac9 commit 8645ef3
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
9 changes: 9 additions & 0 deletions cerberus-dashboard/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@ node {
}

task buildDashboard(type: NpmTask, dependsOn: npmInstall) {

doFirst {
if (System.getenv("FRONTEND_ENV_FILE_PATH")) {
String file_path = System.getenv("FRONTEND_ENV_FILE_PATH")
assert file(file_path).exists()
new File("${project.projectDir.absolutePath}", ".env").text = file(file_path).text
}
}

group 'build'
args = ["run", "build"]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ const validate = values => {

if (!values.owner) {
errors.owner = 'You must select an owning user group';
} else if (process.env.REACT_APP_AD_GROUP_NAME_PREFIX) {
validateOwner(values.owner, process.env.REACT_APP_AD_GROUP_NAME_PREFIX, errors);
}

if (values.userGroupPermissions) {
Expand All @@ -60,6 +62,12 @@ const validate = values => {
return errors;
};

const validateOwner = (owner, ownerPrefix, errors) => {
if (!owner.toLowerCase().startsWith(ownerPrefix.toLowerCase())) {
errors.owner = 'This AD Group name does not match your organizations specified naming pattern: ' + ownerPrefix;
}
}

const validateUserGroupPermissions = (permission, index, errors) => {
errors.userGroupPermissions[`${index}`] = {};
if (!permission.name) {
Expand Down
12 changes: 10 additions & 2 deletions cerberus-dashboard/src/components/GroupSelect/GroupsSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,16 @@ export default class GroupsSelect extends Component {
render() {
const { userGroups, allowCustomValues, value, onChange, handleBeingTouched, touched, error } = this.props;

var options = userGroups.map(function (group) {
return { label: group, value: group };
var options = [];
userGroups.forEach(group => {
if (process.env.REACT_APP_AD_GROUP_NAME_PREFIX) {
let groupNamingPattern = process.env.REACT_APP_AD_GROUP_NAME_PREFIX.toLowerCase()
if (group.toLowerCase().startsWith(groupNamingPattern)) {
options.push({ label: group, value: group });
}
} else {
options.push({ label: group, value: group });
}
});

var containsValue = false;
Expand Down

0 comments on commit 8645ef3

Please sign in to comment.