diff --git a/spring-vault-core/src/main/java/org/springframework/vault/config/EnvironmentVaultConfiguration.java b/spring-vault-core/src/main/java/org/springframework/vault/config/EnvironmentVaultConfiguration.java index bd857b90..f5aeb447 100644 --- a/spring-vault-core/src/main/java/org/springframework/vault/config/EnvironmentVaultConfiguration.java +++ b/spring-vault-core/src/main/java/org/springframework/vault/config/EnvironmentVaultConfiguration.java @@ -112,6 +112,8 @@ import org.springframework.web.client.RestOperations; * *
  • AppId authentication * *
  • AppRole authentication * *
  • AWS EC2 authentication * *
  • Azure MSI authentication * *
  • Client Certificate authentication @@ -139,10 +147,20 @@ import org.springframework.web.client.RestOperations; * + *
  • Kubernetes authentication + * * * * @author Mark Paluch * @author Michal Budzyn + * @author Raoof Mohammed * @see org.springframework.core.env.Environment * @see org.springframework.core.env.PropertySource * @see VaultEndpoint @@ -222,8 +240,8 @@ public class EnvironmentVaultConfiguration extends AbstractVaultConfiguration @Override public ClientAuthentication clientAuthentication() { - String authentication = getProperty("vault.authentication", AuthenticationMethod.TOKEN.name()) - .toUpperCase().replace('-', '_'); + String authentication = getProperty("vault.authentication", + AuthenticationMethod.TOKEN.name()).toUpperCase().replace('-', '_'); AuthenticationMethod authenticationMethod = AuthenticationMethod .valueOf(authentication); @@ -268,7 +286,8 @@ public class EnvironmentVaultConfiguration extends AbstractVaultConfiguration protected ClientAuthentication appIdAuthentication() { - String appId = getProperty("vault.app-id.app-id", getProperty("spring.application.name")); + String appId = getProperty("vault.app-id.app-id", + getProperty("spring.application.name")); String userId = getProperty("vault.app-id.user-id"); String path = getProperty("vault.app-id.app-id-path", AppIdAuthenticationOptions.DEFAULT_APPID_AUTHENTICATION_PATH); @@ -278,11 +297,8 @@ public class EnvironmentVaultConfiguration extends AbstractVaultConfiguration Assert.hasText(userId, "Vault AppId authentication: UserId (vault.app-id.user-id) must not be empty"); - AppIdAuthenticationOptionsBuilder builder = AppIdAuthenticationOptions - .builder() - .appId(appId) - .userIdMechanism(getAppIdUserIdMechanism(userId)) - .path(path); + AppIdAuthenticationOptionsBuilder builder = AppIdAuthenticationOptions.builder() + .appId(appId).userIdMechanism(getAppIdUserIdMechanism(userId)).path(path); return new AppIdAuthentication(builder.build(), restOperations()); } @@ -293,14 +309,12 @@ public class EnvironmentVaultConfiguration extends AbstractVaultConfiguration String secretId = getProperty("vault.app-role.secret-id"); String path = getProperty("vault.app-role.app-role-path", AppRoleAuthenticationOptions.DEFAULT_APPROLE_AUTHENTICATION_PATH); - + Assert.hasText(roleId, "Vault AppRole authentication: RoleId (vault.app-role.role-id) must not be empty"); AppRoleAuthenticationOptionsBuilder builder = AppRoleAuthenticationOptions - .builder() - .roleId(RoleId.provided(roleId)) - .path(path); + .builder().roleId(RoleId.provided(roleId)).path(path); if (StringUtils.hasText(secretId)) { builder = builder.secretId(SecretId.provided(secretId)); @@ -328,14 +342,12 @@ public class EnvironmentVaultConfiguration extends AbstractVaultConfiguration String identityDocument = getProperty("vault.aws-ec2.identity-document"); String path = getProperty("vault.aws-ec2.aws-ec2-path", AwsEc2AuthenticationOptions.DEFAULT_AWS_AUTHENTICATION_PATH); - + Assert.hasText(roleId, "Vault AWS EC2 authentication: RoleId (vault.aws-ec2.role-id) must not be empty"); - AwsEc2AuthenticationOptionsBuilder builder = AwsEc2AuthenticationOptions - .builder() - .role(roleId) - .path(path); + AwsEc2AuthenticationOptionsBuilder builder = AwsEc2AuthenticationOptions.builder() + .role(roleId).path(path); if (StringUtils.hasText(identityDocument)) { builder.identityDocumentUri(URI.create(identityDocument)); @@ -350,14 +362,12 @@ public class EnvironmentVaultConfiguration extends AbstractVaultConfiguration String roleId = getProperty("vault.azure-msi.role"); String path = getProperty("vault.azure-msi.azure-path", AzureMsiAuthenticationOptions.DEFAULT_AZURE_AUTHENTICATION_PATH); - + Assert.hasText(roleId, "Vault Azure MSI authentication: Role (vault.azure-msi.role) must not be empty"); AzureMsiAuthenticationOptionsBuilder builder = AzureMsiAuthenticationOptions - .builder() - .role(roleId) - .path(path); + .builder().role(roleId).path(path); return new AzureMsiAuthentication(builder.build(), restOperations()); } @@ -369,9 +379,7 @@ public class EnvironmentVaultConfiguration extends AbstractVaultConfiguration "Vault Cubbyhole authentication: Initial token (vault.token) must not be empty"); CubbyholeAuthenticationOptionsBuilder builder = CubbyholeAuthenticationOptions - .builder() - .wrapped() - .initialToken(VaultToken.of(token)); + .builder().wrapped().initialToken(VaultToken.of(token)); return new CubbyholeAuthentication(builder.build(), restOperations()); } @@ -390,10 +398,7 @@ public class EnvironmentVaultConfiguration extends AbstractVaultConfiguration tokenFile); KubernetesAuthenticationOptionsBuilder builder = KubernetesAuthenticationOptions - .builder() - .role(role) - .jwtSupplier(jwtSupplier) - .path(path); + .builder().role(role).jwtSupplier(jwtSupplier).path(path); return new KubernetesAuthentication(builder.build(), restOperations()); }