use of com.netflix.spinnaker.halyard.config.model.v1.security.RoleProvider 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.RoleProvider in project halyard by spinnaker.
the class AbstractEditRoleProviderCommand method executeThis.
@Override
protected void executeThis() {
String currentDeployment = getCurrentDeployment();
String roleProviderName = getRoleProviderType() + "";
// Disable validation here, since we don't want an illegal config to prevent us from fixing it.
RoleProvider roleProvider = new OperationHandler<RoleProvider>().setOperation(Daemon.getRoleProvider(currentDeployment, roleProviderName, false)).setFailureMesssage("Failed to get " + roleProviderName + " method.").get();
new OperationHandler<Void>().setOperation(Daemon.setRoleProvider(currentDeployment, roleProviderName, !noValidate, editRoleProvider((T) roleProvider))).setFailureMesssage("Failed to edit " + roleProviderName + " method.").setSuccessMessage("Successfully edited " + roleProviderName + " method.").get();
}
Aggregations