use of com.netflix.spinnaker.halyard.config.model.v1.security.GroupMembership in project halyard by spinnaker.
the class SecurityController method setRoleProvider.
@RequestMapping(value = "/authz/groupMembership/{roleProviderName:.+}", method = RequestMethod.PUT)
DaemonTask<Halconfig, Void> setRoleProvider(@PathVariable String deploymentName, @PathVariable String roleProviderName, @RequestParam(required = false, defaultValue = DefaultControllerValues.validate) boolean validate, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Severity severity, @RequestBody Object rawProvider) {
RoleProvider roleProvider = objectMapper.convertValue(rawProvider, GroupMembership.translateRoleProviderType(roleProviderName));
UpdateRequestBuilder builder = new UpdateRequestBuilder();
Path configPath = halconfigDirectoryStructure.getConfigPath(deploymentName);
builder.setStage(() -> roleProvider.stageLocalFiles(configPath));
builder.setSeverity(severity);
builder.setUpdate(() -> securityService.setRoleProvider(deploymentName, roleProvider));
builder.setValidate(ProblemSet::new);
if (validate) {
builder.setValidate(() -> securityService.validateRoleProvider(deploymentName, roleProviderName));
}
builder.setRevert(() -> halconfigParser.undoChanges());
builder.setSave(() -> halconfigParser.saveConfig());
builder.setClean(() -> halconfigParser.cleanLocalFiles(configPath));
return DaemonTaskHandler.submitTask(builder::build, "Edit " + roleProviderName + " group membership settings");
}
use of com.netflix.spinnaker.halyard.config.model.v1.security.GroupMembership in project halyard by spinnaker.
the class SecurityController method setGroupMembership.
@RequestMapping(value = "/authz/groupMembership", method = RequestMethod.PUT)
DaemonTask<Halconfig, Void> setGroupMembership(@PathVariable String deploymentName, @RequestParam(required = false, defaultValue = DefaultControllerValues.validate) boolean validate, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Severity severity, @RequestBody Object rawMembership) {
GroupMembership membership = objectMapper.convertValue(rawMembership, GroupMembership.class);
UpdateRequestBuilder builder = new UpdateRequestBuilder();
Path configPath = halconfigDirectoryStructure.getConfigPath(deploymentName);
builder.setStage(() -> membership.stageLocalFiles(configPath));
builder.setSeverity(severity);
builder.setUpdate(() -> securityService.setGroupMembership(deploymentName, membership));
builder.setValidate(ProblemSet::new);
if (validate) {
builder.setValidate(() -> securityService.validateAuthz(deploymentName));
}
builder.setRevert(() -> halconfigParser.undoChanges());
builder.setSave(() -> halconfigParser.saveConfig());
builder.setClean(() -> halconfigParser.cleanLocalFiles(configPath));
return DaemonTaskHandler.submitTask(builder::build, "Edit group membership settings");
}
use of com.netflix.spinnaker.halyard.config.model.v1.security.GroupMembership in project halyard by spinnaker.
the class AuthzEditCommand method executeThis.
@Override
protected void executeThis() {
String currentDeployment = getCurrentDeployment();
GroupMembership membership = new OperationHandler<GroupMembership>().setOperation(Daemon.getGroupMembership(currentDeployment, false)).setFailureMesssage("Failed to get configured roles.").get();
membership.setService(type != null ? type : membership.getService());
new OperationHandler<Void>().setOperation(Daemon.setGroupMembership(currentDeployment, !noValidate, membership)).setFailureMesssage("Failed to set configured roles.").setSuccessMessage("Successfully updated roles.").get();
}
Aggregations