Changes for 5.0.0 release
This commit is contained in:
20
.github/dependabot.yml
vendored
20
.github/dependabot.yml
vendored
@@ -10,6 +10,11 @@ updates:
|
||||
target-branch: "4.2.x"
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
- package-ecosystem: "github-actions"
|
||||
directory: "/"
|
||||
target-branch: "4.3.x"
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
- package-ecosystem: "github-actions"
|
||||
directory: "/"
|
||||
target-branch: "main"
|
||||
@@ -41,12 +46,18 @@ updates:
|
||||
directory: /
|
||||
schedule:
|
||||
interval: daily
|
||||
target-branch: main
|
||||
target-branch: 4.3.x
|
||||
ignore:
|
||||
# only upgrade by minor or patch
|
||||
# only upgrade patch versions for maintenance branch
|
||||
- dependency-name: "*"
|
||||
update-types:
|
||||
- version-update:semver-major
|
||||
- version-update:semver-minor
|
||||
- package-ecosystem: maven
|
||||
directory: /
|
||||
schedule:
|
||||
interval: daily
|
||||
target-branch: main
|
||||
- package-ecosystem: npm
|
||||
target-branch: docs-build
|
||||
directory: /
|
||||
@@ -67,3 +78,8 @@ updates:
|
||||
directory: /docs
|
||||
schedule:
|
||||
interval: weekly
|
||||
- package-ecosystem: npm
|
||||
target-branch: 4.3.x
|
||||
directory: /docs
|
||||
schedule:
|
||||
interval: weekly
|
||||
|
||||
4
.github/workflows/maven.yaml
vendored
4
.github/workflows/maven.yaml
vendored
@@ -5,9 +5,9 @@ name: Build
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [ main, 4.2.x, 4.1.x, 4.0.x, 3.1.x ]
|
||||
branches: [ main, 4.3.x, 4.2.x, 4.1.x, 4.0.x, 3.1.x ]
|
||||
pull_request:
|
||||
branches: [ main, 4.2.x, 4.1.x, 4.0.x, 3.1.x ]
|
||||
branches: [ main, 4.3.x, 4.2.x, 4.1.x, 4.0.x, 3.1.x ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-config</artifactId>
|
||||
<version>4.3.1-SNAPSHOT</version>
|
||||
<version>5.0.0-SNAPSHOT</version>
|
||||
<relativePath>..</relativePath>
|
||||
</parent>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
12
pom.xml
12
pom.xml
@@ -5,7 +5,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-config</artifactId>
|
||||
<version>4.3.1-SNAPSHOT</version>
|
||||
<version>5.0.0-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
<name>Spring Cloud Config</name>
|
||||
<description>Spring Cloud Config</description>
|
||||
@@ -13,7 +13,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-build</artifactId>
|
||||
<version>4.3.1-SNAPSHOT</version>
|
||||
<version>5.0.0-SNAPSHOT</version>
|
||||
<relativePath/> <!-- lookup parent from repository -->
|
||||
</parent>
|
||||
<scm>
|
||||
@@ -27,9 +27,10 @@
|
||||
</scm>
|
||||
<properties>
|
||||
<bintray.package>config</bintray.package>
|
||||
<spring-cloud-commons.version>4.3.1-SNAPSHOT</spring-cloud-commons.version>
|
||||
<spring-cloud-commons.version>5.0.0-SNAPSHOT</spring-cloud-commons.version>
|
||||
<aws-java-sdk.version>2.31.58</aws-java-sdk.version>
|
||||
<google-api-services-iam.version>v1-rev20201112-1.30.10</google-api-services-iam.version>
|
||||
<google-cloud-iamcredentials.version>2.60.0</google-cloud-iamcredentials.version>
|
||||
<wiremock.version>2.35.2</wiremock.version>
|
||||
<spring-cloud-aws.version>3.3.1</spring-cloud-aws.version>
|
||||
<maven-checkstyle-plugin.failsOnError>true</maven-checkstyle-plugin.failsOnError>
|
||||
@@ -82,6 +83,11 @@
|
||||
<artifactId>google-api-services-iam</artifactId>
|
||||
<version>${google-api-services-iam.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.cloud</groupId>
|
||||
<artifactId>google-cloud-iamcredentials</artifactId>
|
||||
<version>${google-cloud-iamcredentials.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.auth</groupId>
|
||||
<artifactId>google-auth-library-oauth2-http</artifactId>
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-config</artifactId>
|
||||
<version>4.3.1-SNAPSHOT</version>
|
||||
<version>5.0.0-SNAPSHOT</version>
|
||||
<relativePath>..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -99,7 +99,7 @@
|
||||
<dependency>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
<artifactId>bcpkix-jdk18on</artifactId>
|
||||
<version>1.80</version>
|
||||
<version>1.81</version>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-config</artifactId>
|
||||
<version>4.3.1-SNAPSHOT</version>
|
||||
<version>5.0.0-SNAPSHOT</version>
|
||||
<relativePath>..</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@@ -124,8 +124,8 @@ public class ConfigServerConfigDataResource extends ConfigDataResource {
|
||||
|
||||
private boolean uriEqual(String thisUriString, String thatUriString) {
|
||||
try {
|
||||
UriComponents thisUri = UriComponentsBuilder.fromHttpUrl(thisUriString).build();
|
||||
UriComponents thatUri = UriComponentsBuilder.fromHttpUrl(thatUriString).build();
|
||||
UriComponents thisUri = UriComponentsBuilder.fromUriString(thisUriString).build();
|
||||
UriComponents thatUri = UriComponentsBuilder.fromUriString(thatUriString).build();
|
||||
return Objects.equals(thisUri.getHost(), thatUri.getHost())
|
||||
&& Objects.equals(thisUri.getPort(), thatUri.getPort())
|
||||
&& Objects.equals(thisUri.getPath(), thatUri.getPath());
|
||||
@@ -138,7 +138,7 @@ public class ConfigServerConfigDataResource extends ConfigDataResource {
|
||||
private int urisHashCode(String[] uris) {
|
||||
return Arrays.stream(uris).mapToInt(uriString -> {
|
||||
try {
|
||||
UriComponents uriComponents = UriComponentsBuilder.fromHttpUrl(uriString).build();
|
||||
UriComponents uriComponents = UriComponentsBuilder.fromUriString(uriString).build();
|
||||
return Objects.hash(uriComponents.getHost(), uriComponents.getPath(), uriComponents.getPort());
|
||||
}
|
||||
catch (Exception e) {
|
||||
|
||||
@@ -263,7 +263,7 @@ public class ConfigServerConfigDataLoaderTests {
|
||||
String username = "user";
|
||||
String password = "pass";
|
||||
factory(properties).addAuthorizationToken(headers, username, password);
|
||||
assertThat(headers).hasSize(1);
|
||||
assertThat(headers.size()).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -272,7 +272,7 @@ public class ConfigServerConfigDataLoaderTests {
|
||||
properties.getHeaders().put(AUTHORIZATION, "Basic dXNlcm5hbWU6cGFzc3dvcmQNCg==");
|
||||
String username = "user";
|
||||
factory(properties).addAuthorizationToken(headers, username, null);
|
||||
assertThat(headers).hasSize(1);
|
||||
assertThat(headers.size()).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -23,7 +23,6 @@ import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
|
||||
import org.springframework.beans.factory.support.InstanceSupplier;
|
||||
import org.springframework.boot.BootstrapRegistry;
|
||||
import org.springframework.boot.ConfigurableBootstrapContext;
|
||||
import org.springframework.boot.context.config.ConfigDataLocation;
|
||||
|
||||
@@ -254,7 +254,7 @@ public class ConfigServicePropertySourceLocatorTests {
|
||||
String username = "user";
|
||||
String password = "pass";
|
||||
factory(defaults).addAuthorizationToken(headers, username, password);
|
||||
assertThat(headers).hasSize(1);
|
||||
assertThat(headers.size()).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -265,7 +265,7 @@ public class ConfigServicePropertySourceLocatorTests {
|
||||
String username = "user";
|
||||
String password = null;
|
||||
factory(defaults).addAuthorizationToken(headers, username, password);
|
||||
assertThat(headers).hasSize(1);
|
||||
assertThat(headers.size()).isEqualTo(1);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -6,17 +6,17 @@
|
||||
<parent>
|
||||
<artifactId>spring-cloud-dependencies-parent</artifactId>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<version>4.3.1-SNAPSHOT</version>
|
||||
<version>5.0.0-SNAPSHOT</version>
|
||||
<relativePath/>
|
||||
</parent>
|
||||
<artifactId>spring-cloud-config-dependencies</artifactId>
|
||||
<version>4.3.1-SNAPSHOT</version>
|
||||
<version>5.0.0-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
<name>spring-cloud-config-dependencies</name>
|
||||
<description>Spring Cloud Config Dependencies</description>
|
||||
<properties>
|
||||
<jgit.version>6.10.1.202505221210-r</jgit.version>
|
||||
<spring-vault.version>3.2.0</spring-vault.version>
|
||||
<spring-vault.version>4.0.0-SNAPSHOT</spring-vault.version>
|
||||
<spring-credhub.version>2.1.1.RELEASE</spring-credhub.version>
|
||||
<spring-retry.version>2.0.10</spring-retry.version>
|
||||
</properties>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-config</artifactId>
|
||||
<version>4.3.1-SNAPSHOT</version>
|
||||
<version>5.0.0-SNAPSHOT</version>
|
||||
<relativePath>..</relativePath>
|
||||
</parent>
|
||||
<artifactId>spring-cloud-config-monitor</artifactId>
|
||||
@@ -14,7 +14,7 @@
|
||||
<description>Spring Cloud Config Monitor</description>
|
||||
<properties>
|
||||
<main.basedir>${basedir}/../..</main.basedir>
|
||||
<spring-cloud-bus.version>4.3.1-SNAPSHOT</spring-cloud-bus.version>
|
||||
<spring-cloud-bus.version>5.0.0-SNAPSHOT</spring-cloud-bus.version>
|
||||
</properties>
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.util.LinkedHashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
@@ -30,7 +30,7 @@ import org.springframework.util.MultiValueMap;
|
||||
public abstract class BasePropertyPathNotificationExtractor implements PropertyPathNotificationExtractor {
|
||||
|
||||
@Override
|
||||
public PropertyPathNotification extract(MultiValueMap<String, String> headers, Map<String, Object> request) {
|
||||
public PropertyPathNotification extract(HttpHeaders headers, Map<String, Object> request) {
|
||||
if (requestBelongsToGitRepoManager(headers)) {
|
||||
if (request.get("commits") instanceof Collection) {
|
||||
Set<String> paths = new LinkedHashSet<>();
|
||||
@@ -61,6 +61,6 @@ public abstract class BasePropertyPathNotificationExtractor implements PropertyP
|
||||
}
|
||||
}
|
||||
|
||||
protected abstract boolean requestBelongsToGitRepoManager(MultiValueMap<String, String> headers);
|
||||
protected abstract boolean requestBelongsToGitRepoManager(HttpHeaders headers);
|
||||
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ import java.util.Map;
|
||||
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
@@ -34,7 +34,7 @@ import org.springframework.util.StringUtils;
|
||||
public class BitbucketPropertyPathNotificationExtractor implements PropertyPathNotificationExtractor {
|
||||
|
||||
@Override
|
||||
public PropertyPathNotification extract(MultiValueMap<String, String> headers, Map<String, Object> request) {
|
||||
public PropertyPathNotification extract(HttpHeaders headers, Map<String, Object> request) {
|
||||
if (("repo:push".equals(headers.getFirst("X-Event-Key"))
|
||||
|| "pullrequest:fulfilled".equals(headers.getFirst("X-Event-Key")))
|
||||
&& StringUtils.hasText(headers.getFirst("X-Hook-UUID"))) {
|
||||
|
||||
@@ -24,7 +24,7 @@ import java.util.Map;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.annotation.AnnotationAwareOrderComparator;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
|
||||
/**
|
||||
* A {@link PropertyPathNotificationExtractor} that cycles through a set of (ordered)
|
||||
@@ -47,7 +47,7 @@ public class CompositePropertyPathNotificationExtractor implements PropertyPathN
|
||||
}
|
||||
|
||||
@Override
|
||||
public PropertyPathNotification extract(MultiValueMap<String, String> headers, Map<String, Object> request) {
|
||||
public PropertyPathNotification extract(HttpHeaders headers, Map<String, Object> request) {
|
||||
for (PropertyPathNotificationExtractor extractor : this.extractors) {
|
||||
PropertyPathNotification result = extractor.extract(headers, request);
|
||||
if (result != null) {
|
||||
@@ -61,7 +61,7 @@ public class CompositePropertyPathNotificationExtractor implements PropertyPathN
|
||||
private static class SimplePropertyPathNotificationExtractor implements PropertyPathNotificationExtractor {
|
||||
|
||||
@Override
|
||||
public PropertyPathNotification extract(MultiValueMap<String, String> headers, Map<String, Object> request) {
|
||||
public PropertyPathNotification extract(HttpHeaders headers, Map<String, Object> request) {
|
||||
Object object = request.get("path");
|
||||
if (object instanceof String) {
|
||||
return new PropertyPathNotification((String) object);
|
||||
|
||||
@@ -22,7 +22,7 @@ import java.util.Set;
|
||||
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
|
||||
/**
|
||||
* @author Juan Pablo Santos Rodríguez
|
||||
@@ -46,7 +46,7 @@ public class GiteaPropertyPathNotificationExtractor extends BasePropertyPathNoti
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean requestBelongsToGitRepoManager(MultiValueMap<String, String> headers) {
|
||||
protected boolean requestBelongsToGitRepoManager(HttpHeaders headers) {
|
||||
return HEADERS_VALUE.equals(headers.getFirst(HEADERS_KEY));
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.springframework.cloud.config.monitor;
|
||||
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
|
||||
/**
|
||||
* @author lly 835
|
||||
@@ -32,7 +32,7 @@ public class GiteePropertyPathNotificationExtractor extends BasePropertyPathNoti
|
||||
private static final String HEADERS_VALUE = "Push Hook";
|
||||
|
||||
@Override
|
||||
protected boolean requestBelongsToGitRepoManager(MultiValueMap<String, String> headers) {
|
||||
protected boolean requestBelongsToGitRepoManager(HttpHeaders headers) {
|
||||
return HEADERS_VALUE.equals(headers.getFirst(HEADERS_KEY));
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.springframework.cloud.config.monitor;
|
||||
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
@@ -28,7 +28,7 @@ import org.springframework.util.MultiValueMap;
|
||||
public class GithubPropertyPathNotificationExtractor extends BasePropertyPathNotificationExtractor {
|
||||
|
||||
@Override
|
||||
protected boolean requestBelongsToGitRepoManager(MultiValueMap<String, String> headers) {
|
||||
protected boolean requestBelongsToGitRepoManager(HttpHeaders headers) {
|
||||
return "push".equals(headers.getFirst("X-Github-Event"));
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.springframework.cloud.config.monitor;
|
||||
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
|
||||
/**
|
||||
* @author Dave Syer
|
||||
@@ -28,7 +28,7 @@ import org.springframework.util.MultiValueMap;
|
||||
public class GitlabPropertyPathNotificationExtractor extends BasePropertyPathNotificationExtractor {
|
||||
|
||||
@Override
|
||||
protected boolean requestBelongsToGitRepoManager(MultiValueMap<String, String> headers) {
|
||||
protected boolean requestBelongsToGitRepoManager(HttpHeaders headers) {
|
||||
return "Push Hook".equals(headers.getFirst("X-Gitlab-Event"));
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ package org.springframework.cloud.config.monitor;
|
||||
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
|
||||
/**
|
||||
* @author lly 835
|
||||
@@ -32,7 +32,7 @@ public class GogsPropertyPathNotificationExtractor extends BasePropertyPathNotif
|
||||
private static final String HEADERS_VALUE = "push";
|
||||
|
||||
@Override
|
||||
protected boolean requestBelongsToGitRepoManager(MultiValueMap<String, String> headers) {
|
||||
protected boolean requestBelongsToGitRepoManager(HttpHeaders headers) {
|
||||
return HEADERS_VALUE.equals(headers.getFirst(HEADERS_KEY));
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ package org.springframework.cloud.config.monitor;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.util.MultiValueMap;
|
||||
|
||||
/**
|
||||
@@ -30,6 +31,10 @@ import org.springframework.util.MultiValueMap;
|
||||
*/
|
||||
public interface PropertyPathNotificationExtractor {
|
||||
|
||||
PropertyPathNotification extract(MultiValueMap<String, String> headers, Map<String, Object> payload);
|
||||
default PropertyPathNotification extract(MultiValueMap<String, String> headers, Map<String, Object> payload) {
|
||||
return extract(new HttpHeaders(headers), payload);
|
||||
}
|
||||
|
||||
PropertyPathNotification extract(HttpHeaders headers, Map<String, Object> payload);
|
||||
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-config</artifactId>
|
||||
<version>4.3.1-SNAPSHOT</version>
|
||||
<version>5.0.0-SNAPSHOT</version>
|
||||
<relativePath>..</relativePath>
|
||||
</parent>
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-config</artifactId>
|
||||
<version>4.3.1-SNAPSHOT</version>
|
||||
<version>5.0.0-SNAPSHOT</version>
|
||||
<relativePath>..</relativePath>
|
||||
</parent>
|
||||
|
||||
@@ -137,6 +137,11 @@
|
||||
<artifactId>google-cloud-secretmanager</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.cloud</groupId>
|
||||
<artifactId>google-cloud-iamcredentials</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.apis</groupId>
|
||||
<artifactId>google-api-services-cloudresourcemanager</artifactId>
|
||||
|
||||
@@ -17,9 +17,10 @@
|
||||
package org.springframework.cloud.config.server.environment.vault.authentication;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Base64;
|
||||
|
||||
import com.google.api.client.googleapis.auth.oauth2.GoogleCredential;
|
||||
import com.google.auth.oauth2.GoogleCredentials;
|
||||
|
||||
import org.springframework.cloud.config.server.environment.VaultEnvironmentProperties;
|
||||
import org.springframework.cloud.config.server.environment.VaultEnvironmentProperties.AuthenticationMethod;
|
||||
@@ -27,9 +28,8 @@ import org.springframework.cloud.config.server.environment.vault.SpringVaultClie
|
||||
import org.springframework.util.Assert;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.vault.authentication.ClientAuthentication;
|
||||
import org.springframework.vault.authentication.GcpCredentialSupplier;
|
||||
import org.springframework.vault.authentication.GcpIamAuthentication;
|
||||
import org.springframework.vault.authentication.GcpIamAuthenticationOptions;
|
||||
import org.springframework.vault.authentication.GcpIamCredentialsAuthentication;
|
||||
import org.springframework.vault.authentication.GcpIamCredentialsAuthenticationOptions;
|
||||
import org.springframework.web.client.RestOperations;
|
||||
|
||||
public class GcpIamClientAuthenticationProvider extends SpringVaultClientAuthenticationProvider {
|
||||
@@ -49,45 +49,48 @@ public class GcpIamClientAuthenticationProvider extends SpringVaultClientAuthent
|
||||
|
||||
Assert.hasText(gcp.getRole(), missingPropertyForAuthMethod("gcp-iam.role", AuthenticationMethod.GCP_IAM));
|
||||
|
||||
GcpIamAuthenticationOptions.GcpIamAuthenticationOptionsBuilder builder = GcpIamAuthenticationOptions.builder()
|
||||
GcpIamCredentialsAuthenticationOptions.GcpIamCredentialsAuthenticationOptionsBuilder builder = GcpIamCredentialsAuthenticationOptions
|
||||
.builder()
|
||||
.path(gcp.getGcpPath())
|
||||
.role(gcp.getRole())
|
||||
.jwtValidity(gcp.getJwtValidity());
|
||||
|
||||
if (StringUtils.hasText(gcp.getProjectId())) {
|
||||
builder.projectId(gcp.getProjectId());
|
||||
builder.serviceAccountId(gcp.getProjectId());
|
||||
}
|
||||
|
||||
if (StringUtils.hasText(gcp.getServiceAccountId())) {
|
||||
builder.serviceAccountId(gcp.getServiceAccountId());
|
||||
}
|
||||
|
||||
GcpCredentialSupplier supplier = GcpCredentialProvider.getGoogleCredential(gcp);
|
||||
builder.credential(supplier.get());
|
||||
builder.credentials(GcpCredentialProvider.getGoogleCredential(gcp));
|
||||
|
||||
GcpIamAuthenticationOptions options = builder.build();
|
||||
GcpIamCredentialsAuthenticationOptions options = builder.build();
|
||||
|
||||
return new GcpIamAuthentication(options, vaultRestOperations);
|
||||
return new GcpIamCredentialsAuthentication(options, vaultRestOperations);
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
private static class GcpCredentialProvider {
|
||||
|
||||
public static GcpCredentialSupplier getGoogleCredential(VaultEnvironmentProperties.GcpIamProperties gcp) {
|
||||
return () -> {
|
||||
|
||||
public static GoogleCredentials getGoogleCredential(VaultEnvironmentProperties.GcpIamProperties gcp) {
|
||||
try {
|
||||
VaultEnvironmentProperties.GcpCredentials credentialProperties = gcp.getCredentials();
|
||||
if (credentialProperties.getLocation() != null) {
|
||||
return GoogleCredential.fromStream(credentialProperties.getLocation().getInputStream());
|
||||
return GoogleCredentials.fromStream(credentialProperties.getLocation().getInputStream());
|
||||
}
|
||||
|
||||
if (StringUtils.hasText(credentialProperties.getEncodedKey())) {
|
||||
return GoogleCredential.fromStream(
|
||||
return GoogleCredentials.fromStream(
|
||||
new ByteArrayInputStream(Base64.getDecoder().decode(credentialProperties.getEncodedKey())));
|
||||
}
|
||||
|
||||
return GoogleCredential.getApplicationDefault();
|
||||
};
|
||||
return GoogleCredentials.getApplicationDefault();
|
||||
}
|
||||
catch (IOException e) {
|
||||
// TODO log
|
||||
return GoogleCredentials.newBuilder().build();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ public class VanillaConfigServerIntegrationTests {
|
||||
ResponseEntity<Environment> response = new TestRestTemplate().exchange(
|
||||
"http://localhost:" + this.port + "/invalid/default", HttpMethod.GET, getV2AcceptEntity(),
|
||||
Environment.class);
|
||||
assertThat(response.getStatusCodeValue()).isEqualTo(500);
|
||||
assertThat(response.getStatusCode().value()).isEqualTo(500);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -71,7 +71,8 @@ public class VaultEnvironmentRepositoryTests {
|
||||
assertThat(e.getPropertySources().get(1).getName()).isEqualTo("vault:application");
|
||||
assertThat(e.getPropertySources().get(1).getSource()).isEqualTo(Map.of("def-foo", "def-bar"));
|
||||
|
||||
assertThat(requestHeaderCaptor.getValue().getHeaders()).containsEntry("X-Vault-Token", List.of("token"));
|
||||
assertThat(requestHeaderCaptor.getValue().getHeaders().containsHeader("X-Vault-Token")).isTrue();
|
||||
assertThat(requestHeaderCaptor.getValue().getHeaders().get("X-Vault-Token")).isEqualTo(List.of("token"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -244,7 +245,8 @@ public class VaultEnvironmentRepositoryTests {
|
||||
assertThat(e.getPropertySources().get(1).getName()).isEqualTo("vault:application");
|
||||
assertThat(e.getPropertySources().get(1).getSource()).isEqualTo(Map.of("def-foo", "def-bar"));
|
||||
|
||||
assertThat(requestHeaderCaptor.getValue().getHeaders()).containsEntry("X-Vault-Token", List.of("token"));
|
||||
assertThat(requestHeaderCaptor.getValue().getHeaders().containsHeader("X-Vault-Token")).isTrue();
|
||||
assertThat(requestHeaderCaptor.getValue().getHeaders().get("X-Vault-Token")).isEqualTo(List.of("token"));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -277,9 +279,11 @@ public class VaultEnvironmentRepositoryTests {
|
||||
|
||||
vaultEnvironmentRepository(properties).findOne("myapp", null, "lbl");
|
||||
|
||||
assertThat(requestHeaderCaptor.getValue().getHeaders()).containsEntry("X-Vault-Namespace",
|
||||
List.of("mynamespace"));
|
||||
assertThat(requestHeaderCaptor.getValue().getHeaders()).containsEntry("X-Vault-Token", List.of("token"));
|
||||
assertThat(requestHeaderCaptor.getValue().getHeaders().containsHeader("X-Vault-Namespace")).isTrue();
|
||||
assertThat(requestHeaderCaptor.getValue().getHeaders().get("X-Vault-Namespace"))
|
||||
.isEqualTo(List.of("mynamespace"));
|
||||
assertThat(requestHeaderCaptor.getValue().getHeaders().containsHeader("X-Vault-Token")).isTrue();
|
||||
assertThat(requestHeaderCaptor.getValue().getHeaders().get("X-Vault-Token")).isEqualTo(List.of("token"));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -63,7 +63,7 @@ import org.springframework.vault.authentication.ClientAuthentication;
|
||||
import org.springframework.vault.authentication.ClientCertificateAuthentication;
|
||||
import org.springframework.vault.authentication.CubbyholeAuthentication;
|
||||
import org.springframework.vault.authentication.GcpComputeAuthentication;
|
||||
import org.springframework.vault.authentication.GcpIamAuthentication;
|
||||
import org.springframework.vault.authentication.GcpIamCredentialsAuthentication;
|
||||
import org.springframework.vault.authentication.KubernetesAuthentication;
|
||||
import org.springframework.vault.authentication.PcfAuthentication;
|
||||
import org.springframework.vault.authentication.TokenAuthentication;
|
||||
@@ -231,7 +231,7 @@ class SpringVaultClientConfigurationTests {
|
||||
properties.getGcpIam().setServiceAccountId("service-account");
|
||||
properties.getGcpIam().getCredentials().setEncodedKey(base64(GCE_JSON));
|
||||
|
||||
assertClientAuthenticationOfType(properties, GcpIamAuthentication.class);
|
||||
assertClientAuthenticationOfType(properties, GcpIamCredentialsAuthentication.class);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -6,10 +6,10 @@
|
||||
<parent>
|
||||
<groupId>org.springframework.cloud</groupId>
|
||||
<artifactId>spring-cloud-config</artifactId>
|
||||
<version>4.3.1-SNAPSHOT</version>
|
||||
<version>5.0.0-SNAPSHOT</version>
|
||||
</parent>
|
||||
<artifactId>spring-cloud-starter-config</artifactId>
|
||||
<version>4.3.1-SNAPSHOT</version>
|
||||
<version>5.0.0-SNAPSHOT</version>
|
||||
<name>spring-cloud-starter-config</name>
|
||||
<description>Spring Cloud Starter</description>
|
||||
<url>https://projects.spring.io/spring-cloud</url>
|
||||
|
||||
Reference in New Issue
Block a user