use of com.netflix.spinnaker.halyard.config.model.v1.security.AuthnMethod in project halyard by spinnaker.
the class SecurityController method setAuthnMethod.
@RequestMapping(value = "/authn/{methodName:.+}", method = RequestMethod.PUT)
DaemonTask<Halconfig, Void> setAuthnMethod(@PathVariable String deploymentName, @PathVariable String methodName, @RequestParam(required = false, defaultValue = DefaultControllerValues.validate) boolean validate, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Severity severity, @RequestBody Object rawMethod) {
AuthnMethod method = objectMapper.convertValue(rawMethod, AuthnMethod.translateAuthnMethodName(methodName));
UpdateRequestBuilder builder = new UpdateRequestBuilder();
Path configPath = halconfigDirectoryStructure.getConfigPath(deploymentName);
builder.setStage(() -> method.stageLocalFiles(configPath));
builder.setSeverity(severity);
builder.setUpdate(() -> securityService.setAuthnMethod(deploymentName, method));
builder.setValidate(ProblemSet::new);
if (validate) {
builder.setValidate(() -> securityService.validateAuthnMethod(deploymentName, methodName));
}
builder.setRevert(() -> halconfigParser.undoChanges());
builder.setSave(() -> halconfigParser.saveConfig());
builder.setClean(() -> halconfigParser.cleanLocalFiles(configPath));
return DaemonTaskHandler.submitTask(builder::build, "Edit " + methodName + " authentication settings");
}
use of com.netflix.spinnaker.halyard.config.model.v1.security.AuthnMethod in project halyard by spinnaker.
the class AbstractEditAuthnMethodCommand method executeThis.
@Override
protected void executeThis() {
String currentDeployment = getCurrentDeployment();
String authnMethodName = getMethod().id;
// Disable validation here, since we don't want an illegal config to prevent us from fixing it.
AuthnMethod authnMethod = new OperationHandler<AuthnMethod>().setOperation(Daemon.getAuthnMethod(currentDeployment, authnMethodName, false)).setFailureMesssage("Failed to get " + authnMethodName + " method.").get();
new OperationHandler<Void>().setOperation(Daemon.setAuthnMethod(currentDeployment, authnMethodName, !noValidate, editAuthnMethod((T) authnMethod))).setFailureMesssage("Failed to edit " + authnMethodName + " method.").setSuccessMessage("Successfully edited " + authnMethodName + " method.").get();
}
Aggregations