Search in sources :

Example 1 with RoleProvider

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

Example 2 with RoleProvider

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

Aggregations

RoleProvider (com.netflix.spinnaker.halyard.config.model.v1.security.RoleProvider)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