Search in sources :

Example 1 with Security

use of com.netflix.spinnaker.halyard.config.model.v1.security.Security in project halyard by spinnaker.

the class SecurityController method setUiSecurity.

@RequestMapping(value = "/ui/", method = RequestMethod.PUT)
DaemonTask<Halconfig, Void> setUiSecurity(@PathVariable String deploymentName, @RequestParam(required = false, defaultValue = DefaultControllerValues.validate) boolean validate, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Severity severity, @RequestBody Object rawUiSecurity) {
    UiSecurity uiSecurity = objectMapper.convertValue(rawUiSecurity, UiSecurity.class);
    UpdateRequestBuilder builder = new UpdateRequestBuilder();
    Path configPath = halconfigDirectoryStructure.getConfigPath(deploymentName);
    builder.setStage(() -> uiSecurity.stageLocalFiles(configPath));
    builder.setSeverity(severity);
    builder.setUpdate(() -> securityService.setUiSecurity(deploymentName, uiSecurity));
    builder.setValidate(ProblemSet::new);
    if (validate) {
        builder.setValidate(() -> securityService.validateUiSecurity(deploymentName));
    }
    builder.setRevert(() -> halconfigParser.undoChanges());
    builder.setSave(() -> halconfigParser.saveConfig());
    builder.setClean(() -> halconfigParser.cleanLocalFiles(configPath));
    return DaemonTaskHandler.submitTask(builder::build, "Edit UI security settings");
}
Also used : Path(java.nio.file.Path) UiSecurity(com.netflix.spinnaker.halyard.config.model.v1.security.UiSecurity) 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 Security

use of com.netflix.spinnaker.halyard.config.model.v1.security.Security in project halyard by spinnaker.

the class SecurityController method setSecurity.

@RequestMapping(value = "/", method = RequestMethod.PUT)
DaemonTask<Halconfig, Void> setSecurity(@PathVariable String deploymentName, @RequestParam(required = false, defaultValue = DefaultControllerValues.validate) boolean validate, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Severity severity, @RequestBody Object rawSecurity) {
    Security security = objectMapper.convertValue(rawSecurity, Security.class);
    UpdateRequestBuilder builder = new UpdateRequestBuilder();
    Path configPath = halconfigDirectoryStructure.getConfigPath(deploymentName);
    builder.setStage(() -> security.stageLocalFiles(configPath));
    builder.setSeverity(severity);
    builder.setUpdate(() -> securityService.setSecurity(deploymentName, security));
    builder.setValidate(ProblemSet::new);
    if (validate) {
        builder.setValidate(() -> securityService.validateSecurity(deploymentName));
    }
    builder.setRevert(() -> halconfigParser.undoChanges());
    builder.setSave(() -> halconfigParser.saveConfig());
    builder.setClean(() -> halconfigParser.cleanLocalFiles(configPath));
    return DaemonTaskHandler.submitTask(builder::build, "Edit security settings");
}
Also used : Path(java.nio.file.Path) UpdateRequestBuilder(com.netflix.spinnaker.halyard.core.DaemonResponse.UpdateRequestBuilder) ApiSecurity(com.netflix.spinnaker.halyard.config.model.v1.security.ApiSecurity) Security(com.netflix.spinnaker.halyard.config.model.v1.security.Security) UiSecurity(com.netflix.spinnaker.halyard.config.model.v1.security.UiSecurity) ProblemSet(com.netflix.spinnaker.halyard.core.problem.v1.ProblemSet) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with Security

use of com.netflix.spinnaker.halyard.config.model.v1.security.Security in project halyard by spinnaker.

the class ApiSecurityEditCommand method executeThis.

@Override
protected void executeThis() {
    String currentDeployment = getCurrentDeployment();
    ApiSecurity apiSecurity = new OperationHandler<ApiSecurity>().setOperation(Daemon.getApiSecurity(currentDeployment, false)).setFailureMesssage("Failed to load API security settings.").get();
    int originalHash = apiSecurity.hashCode();
    apiSecurity.setOverrideBaseUrl(isSet(overrideBaseUrl) ? overrideBaseUrl : apiSecurity.getOverrideBaseUrl());
    apiSecurity.setCorsAccessPattern(isSet(corsAccessPattern) ? corsAccessPattern : apiSecurity.getCorsAccessPattern());
    if (originalHash == apiSecurity.hashCode()) {
        AnsiUi.failure("No changes supplied.");
        return;
    }
    new OperationHandler<Void>().setOperation(Daemon.setApiSecurity(currentDeployment, !noValidate, apiSecurity)).setFailureMesssage("Failed to edit API security settings.").setFailureMesssage("Successfully updated API security settings.").get();
}
Also used : ApiSecurity(com.netflix.spinnaker.halyard.config.model.v1.security.ApiSecurity) OperationHandler(com.netflix.spinnaker.halyard.cli.services.v1.OperationHandler)

Example 4 with Security

use of com.netflix.spinnaker.halyard.config.model.v1.security.Security in project halyard by spinnaker.

the class UiSecurityEditCommand method executeThis.

@Override
protected void executeThis() {
    String currentDeployment = getCurrentDeployment();
    UiSecurity uiSecurity = new OperationHandler<UiSecurity>().setOperation(Daemon.getUiSecurity(currentDeployment, false)).setFailureMesssage("Failed to load UI security settings.").get();
    int originalHash = uiSecurity.hashCode();
    uiSecurity.setOverrideBaseUrl(isSet(overrideBaseUrl) ? overrideBaseUrl : uiSecurity.getOverrideBaseUrl());
    if (originalHash == uiSecurity.hashCode()) {
        AnsiUi.failure("No changes supplied.");
        return;
    }
    new OperationHandler<Void>().setOperation(Daemon.setUiSecurity(currentDeployment, !noValidate, uiSecurity)).setFailureMesssage("Failed to edit UI security settings.").setSuccessMessage("Successfully updated UI security settings.").get();
}
Also used : UiSecurity(com.netflix.spinnaker.halyard.config.model.v1.security.UiSecurity) OperationHandler(com.netflix.spinnaker.halyard.cli.services.v1.OperationHandler)

Example 5 with Security

use of com.netflix.spinnaker.halyard.config.model.v1.security.Security in project halyard by spinnaker.

the class SecurityController method setApiSecurity.

@RequestMapping(value = "/api/", method = RequestMethod.PUT)
DaemonTask<Halconfig, Void> setApiSecurity(@PathVariable String deploymentName, @RequestParam(required = false, defaultValue = DefaultControllerValues.validate) boolean validate, @RequestParam(required = false, defaultValue = DefaultControllerValues.severity) Severity severity, @RequestBody Object rawApiSecurity) {
    ApiSecurity apiSecurity = objectMapper.convertValue(rawApiSecurity, ApiSecurity.class);
    UpdateRequestBuilder builder = new UpdateRequestBuilder();
    Path configPath = halconfigDirectoryStructure.getConfigPath(deploymentName);
    builder.setStage(() -> apiSecurity.stageLocalFiles(configPath));
    builder.setSeverity(severity);
    builder.setUpdate(() -> securityService.setApiSecurity(deploymentName, apiSecurity));
    builder.setValidate(ProblemSet::new);
    if (validate) {
        builder.setValidate(() -> securityService.validateApiSecurity(deploymentName));
    }
    builder.setRevert(() -> halconfigParser.undoChanges());
    builder.setSave(() -> halconfigParser.saveConfig());
    builder.setClean(() -> halconfigParser.cleanLocalFiles(configPath));
    return DaemonTaskHandler.submitTask(builder::build, "Edit API security settings");
}
Also used : Path(java.nio.file.Path) UpdateRequestBuilder(com.netflix.spinnaker.halyard.core.DaemonResponse.UpdateRequestBuilder) ApiSecurity(com.netflix.spinnaker.halyard.config.model.v1.security.ApiSecurity) ProblemSet(com.netflix.spinnaker.halyard.core.problem.v1.ProblemSet) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Aggregations

ApiSecurity (com.netflix.spinnaker.halyard.config.model.v1.security.ApiSecurity)4 DeploymentConfiguration (com.netflix.spinnaker.halyard.config.model.v1.node.DeploymentConfiguration)3 UiSecurity (com.netflix.spinnaker.halyard.config.model.v1.security.UiSecurity)3 UpdateRequestBuilder (com.netflix.spinnaker.halyard.core.DaemonResponse.UpdateRequestBuilder)3 ProblemSet (com.netflix.spinnaker.halyard.core.problem.v1.ProblemSet)3 Path (java.nio.file.Path)3 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 OperationHandler (com.netflix.spinnaker.halyard.cli.services.v1.OperationHandler)2 Security (com.netflix.spinnaker.halyard.config.model.v1.security.Security)2 Strings (com.beust.jcommander.Strings)1 Lists (com.beust.jcommander.internal.Lists)1 Node (com.netflix.spinnaker.halyard.config.model.v1.node.Node)1 NodeIterator (com.netflix.spinnaker.halyard.config.model.v1.node.NodeIterator)1 Provider (com.netflix.spinnaker.halyard.config.model.v1.node.Provider)1 Validator (com.netflix.spinnaker.halyard.config.model.v1.node.Validator)1 DockerRegistryReference (com.netflix.spinnaker.halyard.config.model.v1.providers.containers.DockerRegistryReference)1 DCOSAccount (com.netflix.spinnaker.halyard.config.model.v1.providers.dcos.DCOSAccount)1 DCOSCluster (com.netflix.spinnaker.halyard.config.model.v1.providers.dcos.DCOSCluster)1 ConfigProblemSetBuilder (com.netflix.spinnaker.halyard.config.problem.v1.ConfigProblemSetBuilder)1 DockerRegistryReferenceValidation.validateDockerRegistries (com.netflix.spinnaker.halyard.config.validate.v1.providers.dockerRegistry.DockerRegistryReferenceValidation.validateDockerRegistries)1