Search in sources :

Example 1 with AuthnMethod

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");
}
Also used : Path(java.nio.file.Path) AuthnMethod(com.netflix.spinnaker.halyard.config.model.v1.security.AuthnMethod) UpdateRequestBuilder(com.netflix.spinnaker.halyard.core.DaemonResponse.UpdateRequestBuilder) ProblemSet(com.netflix.spinnaker.halyard.core.problem.v1.ProblemSet) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with AuthnMethod

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();
}
Also used : AuthnMethod(com.netflix.spinnaker.halyard.config.model.v1.security.AuthnMethod) OperationHandler(com.netflix.spinnaker.halyard.cli.services.v1.OperationHandler)

Aggregations

AuthnMethod (com.netflix.spinnaker.halyard.config.model.v1.security.AuthnMethod)2 OperationHandler (com.netflix.spinnaker.halyard.cli.services.v1.OperationHandler)1 UpdateRequestBuilder (com.netflix.spinnaker.halyard.core.DaemonResponse.UpdateRequestBuilder)1 ProblemSet (com.netflix.spinnaker.halyard.core.problem.v1.ProblemSet)1 Path (java.nio.file.Path)1 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)1