Skip to content

Commit

Permalink
Bumping versions
Browse files Browse the repository at this point in the history
  • Loading branch information
spring-builds committed Jul 22, 2024
1 parent 9f23f1a commit bb8741c
Show file tree
Hide file tree
Showing 55 changed files with 574 additions and 483 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void shouldCreateIamTokenSecretBackendMetadataFactory() {
properties.setRole("readonly");

SecretBackendMetadataFactory<VaultAwsProperties> factory = new VaultConfigAwsBootstrapConfiguration()
.awsSecretBackendMetadataFactory();
.awsSecretBackendMetadataFactory();

SecretBackendMetadata metadata = factory.createMetadata(properties);

Expand All @@ -55,7 +55,7 @@ void shouldCreateStsTokenSecretBackendMetadataFactory() {
properties.setRole("readonly");

SecretBackendMetadataFactory<VaultAwsProperties> factory = new VaultConfigAwsBootstrapConfiguration()
.awsSecretBackendMetadataFactory();
.awsSecretBackendMetadataFactory();

SecretBackendMetadata metadata = factory.createMetadata(properties);

Expand All @@ -73,7 +73,7 @@ void shouldCreateStsTokenSecretBackendMetadataFactoryWithTtlAndRoleArn() {
properties.setRole("readonly");

SecretBackendMetadataFactory<VaultAwsProperties> factory = new VaultConfigAwsBootstrapConfiguration()
.awsSecretBackendMetadataFactory();
.awsSecretBackendMetadataFactory();

SecretBackendMetadata metadata = factory.createMetadata(properties);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,9 @@ public void before() {
role.put("max_ttl", "3s");
vaultOperations.write(String.format("%s/roles/%s", "consul", "short-readonly"), role);

this.vaultRule.prepare().getVaultOperations().write("secret/VaultConfigConsulConfigDataTests",
Collections.singletonMap("default-key", "default"));
this.vaultRule.prepare()
.getVaultOperations()
.write("secret/VaultConfigConsulConfigDataTests", Collections.singletonMap("default-key", "default"));

SpringApplication application = new SpringApplication(VaultConfigConsulConfigDataTests.Config.class);
application.setWebApplicationType(WebApplicationType.NONE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public void setUp() {
public void shouldCreateCredentialsCorrectly() {

Map<String, Object> secretProperties = this.configOperations.read(forDatabase(this.couchbaseProperties))
.getData();
.getData();

assertThat(secretProperties).containsKeys("spring.couchbase.username", "spring.couchbase.password");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public class MongoSecretIntegrationTests extends IntegrationTestSupport {
private static final String MONGODB_HOST = "localhost";

private static final String ROOT_CREDENTIALS = String
.format("mongodb://springvault:springvault@%s:%d/admin?ssl=false", MONGODB_HOST, MONGODB_PORT);
.format("mongodb://springvault:springvault@%s:%d/admin?ssl=false", MONGODB_HOST, MONGODB_PORT);

private static final String ROLES = "[ \"readWrite\", { \"role\": \"read\", \"db\": \"admin\" } ]";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ public class PostgreSqlSecretIntegrationTests extends IntegrationTestSupport {

private static final int POSTGRES_PORT = 5432;

private static final String CONNECTION_URL = String.format(
"postgresql://springvault:springvault@%s:%d/postgres?sslmode=disable", POSTGRES_HOST, POSTGRES_PORT);
private static final String CONNECTION_URL = String
.format("postgresql://springvault:springvault@%s:%d/postgres?sslmode=disable", POSTGRES_HOST, POSTGRES_PORT);

private static final String CREATE_USER_AND_GRANT_SQL = "CREATE ROLE \"{{name}}\" WITH "
+ "LOGIN PASSWORD '{{password}}' VALID UNTIL '{{expiration}}';\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,11 @@ public void shouldUseAuthenticatedSession() {
@Test
public void shouldConnectUsingCassandraClient() {

try (CqlSession session = CqlSession.builder().withLocalDatacenter("dc1")
.addContactPoint(new InetSocketAddress(CASSANDRA_HOST, CASSANDRA_PORT))
.withAuthCredentials(this.username, this.password).build()) {
try (CqlSession session = CqlSession.builder()
.withLocalDatacenter("dc1")
.addContactPoint(new InetSocketAddress(CASSANDRA_HOST, CASSANDRA_PORT))
.withAuthCredentials(this.username, this.password)
.build()) {
assertThat(session.getMetadata().getKeyspace("system")).isNotEmpty();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class VaultConfigDatabaseBootstrapConfigurationUnitTests {
public void shouldConsiderCredentialPath() {

VaultConfigDatabaseBootstrapConfiguration.DatabaseSecretBackendMetadataFactory factory = new VaultConfigDatabaseBootstrapConfiguration()
.databaseSecretBackendMetadataFactory();
.databaseSecretBackendMetadataFactory();

VaultDatabaseProperties properties = new VaultDatabaseProperties();
properties.setStaticRole(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public class VaultConfigMongoTests {
private static final String MONGODB_HOST = "localhost";

private static final String ROOT_CREDENTIALS = String
.format("mongodb://springvault:springvault@%s:%d/admin?ssl=false", MONGODB_HOST, MONGODB_PORT);
.format("mongodb://springvault:springvault@%s:%d/admin?ssl=false", MONGODB_HOST, MONGODB_PORT);

private static final String ROLES = "[ \"readWrite\", { \"role\": \"read\", \"db\": \"admin\" } ]";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ public class VaultConfigPostgreSqlTests {

private static final int POSTGRES_PORT = 5432;

private static final String CONNECTION_URL = String.format(
"postgresql://springvault:springvault@%s:%d/postgres?sslmode=disable", POSTGRES_HOST, POSTGRES_PORT);
private static final String CONNECTION_URL = String
.format("postgresql://springvault:springvault@%s:%d/postgres?sslmode=disable", POSTGRES_HOST, POSTGRES_PORT);

private static final String CREATE_USER_AND_GRANT_SQL = "CREATE ROLE \"{{name}}\" WITH "
+ "LOGIN PASSWORD '{{password}}' VALID UNTIL '{{expiration}}';\n"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class ClientAuthenticationFactory {
ClientAuthenticationFactory.class.getClassLoader());

private static final boolean googleCredentialsPresent = ClassUtils
.isPresent("com.google.auth.oauth2.GoogleCredentials", ClientAuthenticationFactory.class.getClassLoader());
.isPresent("com.google.auth.oauth2.GoogleCredentials", ClientAuthenticationFactory.class.getClassLoader());

private final VaultProperties vaultProperties;

Expand Down Expand Up @@ -159,9 +159,10 @@ private ClientAuthentication appIdAuthentication(VaultProperties vaultProperties
Assert.hasText(appId.getUserId(), "UserId (spring.cloud.vault.app-id.user-id) must not be empty");

AppIdAuthenticationOptions authenticationOptions = AppIdAuthenticationOptions.builder()
.appId(vaultProperties.getApplicationName()) //
.path(appId.getAppIdPath()) //
.userIdMechanism(getAppIdMechanism(appId)).build();
.appId(vaultProperties.getApplicationName()) //
.path(appId.getAppIdPath()) //
.userIdMechanism(getAppIdMechanism(appId))
.build();

return new AppIdAuthentication(authenticationOptions, this.restOperations);
}
Expand Down Expand Up @@ -209,7 +210,7 @@ static AppRoleAuthenticationOptions getAppRoleAuthenticationOptions(VaultPropert
AppRoleProperties appRole = vaultProperties.getAppRole();

AppRoleAuthenticationOptionsBuilder builder = AppRoleAuthenticationOptions.builder()
.path(appRole.getAppRolePath());
.path(appRole.getAppRolePath());

if (StringUtils.hasText(appRole.getRole())) {
builder.appRole(appRole.getRole());
Expand Down Expand Up @@ -265,11 +266,12 @@ private ClientAuthentication awsEc2Authentication(VaultProperties vaultPropertie
Nonce nonce = StringUtils.hasText(awsEc2.getNonce()) ? Nonce.provided(awsEc2.getNonce().toCharArray())
: Nonce.generated();

AwsEc2AuthenticationOptions authenticationOptions = AwsEc2AuthenticationOptions.builder().role(awsEc2.getRole()) //
.path(awsEc2.getAwsEc2Path()) //
.nonce(nonce) //
.identityDocumentUri(awsEc2.getIdentityDocument()) //
.build();
AwsEc2AuthenticationOptions authenticationOptions = AwsEc2AuthenticationOptions.builder()
.role(awsEc2.getRole()) //
.path(awsEc2.getAwsEc2Path()) //
.nonce(nonce) //
.identityDocumentUri(awsEc2.getIdentityDocument()) //
.build();

return new AwsEc2Authentication(authenticationOptions, this.restOperations, this.externalRestOperations);
}
Expand Down Expand Up @@ -298,7 +300,7 @@ ClientAuthentication awsIamAuthentication(VaultProperties vaultProperties) {
}

builder.path(awsIam.getAwsPath()) //
.credentialsProvider(credentialsProvider);
.credentialsProvider(credentialsProvider);

AwsIamAuthenticationOptions options = builder.credentialsProvider(credentialsProvider).build();

Expand All @@ -312,10 +314,11 @@ private ClientAuthentication azureMsiAuthentication(VaultProperties vaultPropert
Assert.hasText(azureMsi.getRole(), "Azure role (spring.cloud.vault.azure-msi.role) must not be empty");

AzureMsiAuthenticationOptions options = AzureMsiAuthenticationOptions.builder() //
.role(azureMsi.getRole()).path(azureMsi.getAzurePath()) //
.instanceMetadataUri(azureMsi.getMetadataService()) //
.identityTokenServiceUri(azureMsi.getIdentityTokenService()) //
.build();
.role(azureMsi.getRole())
.path(azureMsi.getAzurePath()) //
.instanceMetadataUri(azureMsi.getMetadataService()) //
.identityTokenServiceUri(azureMsi.getIdentityTokenService()) //
.build();

return new AzureMsiAuthentication(options, this.restOperations, this.externalRestOperations);
}
Expand All @@ -326,9 +329,9 @@ private ClientAuthentication cubbyholeAuthentication() {
"Initial Token (spring.cloud.vault.token) for Cubbyhole authentication must not be empty");

CubbyholeAuthenticationOptions options = CubbyholeAuthenticationOptions.builder() //
.wrapped() //
.initialToken(VaultToken.of(this.vaultProperties.getToken())) //
.build();
.wrapped() //
.initialToken(VaultToken.of(this.vaultProperties.getToken())) //
.build();

return new CubbyholeAuthentication(options, this.restOperations);
}
Expand All @@ -340,7 +343,8 @@ private ClientAuthentication gcpGceAuthentication(VaultProperties vaultPropertie
Assert.hasText(gcp.getRole(), "Role (spring.cloud.vault.gcp-gce.role) must not be empty");

GcpComputeAuthenticationOptionsBuilder builder = GcpComputeAuthenticationOptions.builder()
.path(gcp.getGcpPath()).role(gcp.getRole());
.path(gcp.getGcpPath())
.role(gcp.getRole());

if (StringUtils.hasText(gcp.getServiceAccount())) {
builder.serviceAccount(gcp.getServiceAccount());
Expand Down Expand Up @@ -372,8 +376,10 @@ private ClientAuthentication kubernetesAuthentication(VaultProperties vaultPrope
"Service account token file (spring.cloud.vault.kubernetes.service-account-token-file) must not be empty");

KubernetesAuthenticationOptions options = KubernetesAuthenticationOptions.builder()
.path(kubernetes.getKubernetesPath()).role(kubernetes.getRole())
.jwtSupplier(new KubernetesServiceAccountTokenFile(kubernetes.getServiceAccountTokenFile())).build();
.path(kubernetes.getKubernetesPath())
.role(kubernetes.getRole())
.jwtSupplier(new KubernetesServiceAccountTokenFile(kubernetes.getServiceAccountTokenFile()))
.build();

return new KubernetesAuthentication(options, this.restOperations);
}
Expand All @@ -387,7 +393,8 @@ private ClientAuthentication pcfAuthentication(VaultProperties vaultProperties)
Assert.hasText(pcfProperties.getRole(), "Role (spring.cloud.vault.pcf.role) must not be empty");

PcfAuthenticationOptions.PcfAuthenticationOptionsBuilder builder = PcfAuthenticationOptions.builder()
.role(pcfProperties.getRole()).path(pcfProperties.getPcfPath());
.role(pcfProperties.getRole())
.path(pcfProperties.getPcfPath());

if (pcfProperties.getInstanceCertificate() != null) {
builder.instanceCertificate(new ResourceCredentialSupplier(pcfProperties.getInstanceCertificate()));
Expand All @@ -403,7 +410,8 @@ private ClientAuthentication pcfAuthentication(VaultProperties vaultProperties)
private ClientAuthentication certificateAuthentication(VaultProperties vaultProperties) {

ClientCertificateAuthenticationOptions options = ClientCertificateAuthenticationOptions.builder()
.path(vaultProperties.getSsl().getCertAuthPath()).build();
.path(vaultProperties.getSsl().getCertAuthPath())
.build();

return new ClientCertificateAuthentication(options, this.restOperations);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,10 @@ static ClientAuthentication create(VaultProperties vaultProperties, RestOperatio

Assert.hasText(gcp.getRole(), "Role (spring.cloud.vault.gcp-iam.role) must not be empty");

GcpIamAuthenticationOptionsBuilder builder = GcpIamAuthenticationOptions.builder().path(gcp.getGcpPath())
.role(gcp.getRole()).jwtValidity(gcp.getJwtValidity());
GcpIamAuthenticationOptionsBuilder builder = GcpIamAuthenticationOptions.builder()
.path(gcp.getGcpPath())
.role(gcp.getRole())
.jwtValidity(gcp.getJwtValidity());

if (StringUtils.hasText(gcp.getProjectId())) {
builder.projectId(gcp.getProjectId());
Expand All @@ -76,8 +78,8 @@ private static GoogleCredential getGoogleCredential(GcpIamProperties gcp) throws
}

if (StringUtils.hasText(credentialProperties.getEncodedKey())) {
return GoogleCredential.fromStream(
new ByteArrayInputStream(Base64.getDecoder().decode(credentialProperties.getEncodedKey())));
return GoogleCredential
.fromStream(new ByteArrayInputStream(Base64.getDecoder().decode(credentialProperties.getEncodedKey())));
}

return GoogleCredential.getApplicationDefault();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ static ClientAuthentication create(VaultProperties vaultProperties, RestOperatio
Assert.hasText(gcp.getRole(), "Role (spring.cloud.vault.gcp-iam.role) must not be empty");

GcpIamCredentialsAuthenticationOptionsBuilder builder = GcpIamCredentialsAuthenticationOptions.builder()
.path(gcp.getGcpPath()).role(gcp.getRole()).jwtValidity(gcp.getJwtValidity());
.path(gcp.getGcpPath())
.role(gcp.getRole())
.jwtValidity(gcp.getJwtValidity());

if (StringUtils.hasText(gcp.getServiceAccountId())) {
builder.serviceAccountId(gcp.getServiceAccountId());
Expand All @@ -73,8 +75,8 @@ private static GoogleCredentials getGoogleCredential(GcpIamProperties gcp) throw
}

if (StringUtils.hasText(credentialProperties.getEncodedKey())) {
return GoogleCredentials.fromStream(
new ByteArrayInputStream(Base64.getDecoder().decode(credentialProperties.getEncodedKey())));
return GoogleCredentials
.fromStream(new ByteArrayInputStream(Base64.getDecoder().decode(credentialProperties.getEncodedKey())));
}

return GoogleCredentials.getApplicationDefault();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ PropertySourceLocatorConfiguration getPropertySourceConfiguration(

if (this.configurers.isEmpty()) {
secretBackendConfigurer.registerDefaultKeyValueSecretBackends(true)
.registerDefaultDiscoveredSecretBackends(true);
.registerDefaultDiscoveredSecretBackends(true);
}
else {

Expand All @@ -75,20 +75,20 @@ PropertySourceLocatorConfiguration getPropertySourceConfiguration(

for (String context : contexts) {
secretBackendConfigurer
.add(KeyValueSecretBackendMetadata.create(keyValueBackend.getBackend(), context));
.add(KeyValueSecretBackendMetadata.create(keyValueBackend.getBackend(), context));
}
}

Collection<SecretBackendMetadata> backendAccessors = SecretBackendFactories
.createSecretBackendMetadata(this.vaultSecretBackendDescriptors, this.factories);
.createSecretBackendMetadata(this.vaultSecretBackendDescriptors, this.factories);

backendAccessors.forEach(secretBackendConfigurer::add);
}

if (secretBackendConfigurer.isRegisterDefaultDiscoveredSecretBackends()) {

Collection<SecretBackendMetadata> backendAccessors = SecretBackendFactories
.createSecretBackendMetadata(this.vaultSecretBackendDescriptors, this.factories);
.createSecretBackendMetadata(this.vaultSecretBackendDescriptors, this.factories);

backendAccessors.forEach(secretBackendConfigurer::add);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,14 @@ public VaultBootstrapPropertySourceConfiguration(VaultProperties vaultProperties
public void afterPropertiesSet() {

this.vaultSecretBackendDescriptors = this.applicationContext.getBeansOfType(VaultSecretBackendDescriptor.class)
.values();
.values();

this.vaultSecretBackendDescriptorFactories = this.applicationContext
.getBeansOfType(VaultSecretBackendDescriptorFactory.class).values();
.getBeansOfType(VaultSecretBackendDescriptorFactory.class)
.values();

this.factories = (Collection) this.applicationContext.getBeansOfType(SecretBackendMetadataFactory.class)
.values();
.values();
}

@Bean
Expand All @@ -101,7 +102,7 @@ public PropertySourceLocator vaultPropertySourceLocator(VaultOperations operatio
VaultConfigTemplate vaultConfigTemplate = new VaultConfigTemplate(operations, vaultProperties);

Collection<VaultConfigurer> vaultConfigurers = this.applicationContext.getBeansOfType(VaultConfigurer.class)
.values();
.values();

List<VaultSecretBackendDescriptor> descriptors = new ArrayList<>(this.vaultSecretBackendDescriptors);
this.vaultSecretBackendDescriptorFactories.forEach(it -> descriptors.addAll(it.create()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ private ConfigData loadConfigData(VaultConfigLocation location, ConfigurableBoot

bootstrap.addCloseListener(event -> {
((ApplicationEventPublisherAware) location.getSecretBackendMetadata())
.setApplicationEventPublisher(event.getApplicationContext());
.setApplicationEventPublisher(event.getApplicationContext());
});
}

Expand Down Expand Up @@ -502,7 +502,7 @@ void registerClientAuthentication() {
registerIfAbsent(this.bootstrap, "clientAuthentication", ClientAuthentication.class, ctx -> {

ClientHttpRequestFactory factory = this.bootstrap.get(ClientFactoryWrapper.class)
.getClientHttpRequestFactory();
.getClientHttpRequestFactory();

RestTemplate externalRestTemplate = new RestTemplate(factory);

Expand Down Expand Up @@ -546,7 +546,7 @@ static class ReactiveInfrastructure {
this.bootstrap = bootstrap;
this.configuration = new VaultReactiveConfiguration(vaultProperties);
this.endpointProvider = SimpleVaultEndpointProvider
.of(new VaultConfiguration(vaultProperties).createVaultEndpoint());
.of(new VaultConfiguration(vaultProperties).createVaultEndpoint());
this.logFactory = logFactory;
}

Expand Down Expand Up @@ -601,7 +601,7 @@ void registerReactiveSessionManager() {
void registerSessionManager() {
registerIfAbsent(this.bootstrap, "vaultSessionManager", SessionManager.class, ctx -> {
SessionManager sessionManager = this.configuration
.createSessionManager(ctx.get(ReactiveSessionManager.class));
.createSessionManager(ctx.get(ReactiveSessionManager.class));
reconfigureLogger(sessionManager, this.logFactory);
return sessionManager;
});
Expand Down
Loading

0 comments on commit bb8741c

Please sign in to comment.