diff --git a/cerberus-dashboard/build.gradle b/cerberus-dashboard/build.gradle index f5911f220..42eddfc0b 100644 --- a/cerberus-dashboard/build.gradle +++ b/cerberus-dashboard/build.gradle @@ -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"] } diff --git a/cerberus-dashboard/src/components/CreateSDBoxForm/validator.js b/cerberus-dashboard/src/components/CreateSDBoxForm/validator.js index bc86320aa..8847b1924 100644 --- a/cerberus-dashboard/src/components/CreateSDBoxForm/validator.js +++ b/cerberus-dashboard/src/components/CreateSDBoxForm/validator.js @@ -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) { @@ -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) { diff --git a/cerberus-dashboard/src/components/GroupSelect/GroupsSelect.js b/cerberus-dashboard/src/components/GroupSelect/GroupsSelect.js index 2f18369bc..055acfae9 100644 --- a/cerberus-dashboard/src/components/GroupSelect/GroupsSelect.js +++ b/cerberus-dashboard/src/components/GroupSelect/GroupsSelect.js @@ -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;