ClientRegistration.redirectUri -> redirectUriTemplate
Fixes gh-4827
This commit is contained in:
parent
e098c3707e
commit
dd33f0a7de
|
@ -100,7 +100,7 @@ public enum CommonOAuth2Provider {
|
||||||
ClientRegistration.Builder builder = ClientRegistration.withRegistrationId(registrationId);
|
ClientRegistration.Builder builder = ClientRegistration.withRegistrationId(registrationId);
|
||||||
builder.clientAuthenticationMethod(method);
|
builder.clientAuthenticationMethod(method);
|
||||||
builder.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE);
|
builder.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE);
|
||||||
builder.redirectUri(redirectUri);
|
builder.redirectUriTemplate(redirectUri);
|
||||||
return builder;
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -51,7 +51,7 @@ public class CommonOAuth2ProviderTests {
|
||||||
.isEqualTo(ClientAuthenticationMethod.BASIC);
|
.isEqualTo(ClientAuthenticationMethod.BASIC);
|
||||||
assertThat(registration.getAuthorizationGrantType())
|
assertThat(registration.getAuthorizationGrantType())
|
||||||
.isEqualTo(AuthorizationGrantType.AUTHORIZATION_CODE);
|
.isEqualTo(AuthorizationGrantType.AUTHORIZATION_CODE);
|
||||||
assertThat(registration.getRedirectUri()).isEqualTo(DEFAULT_LOGIN_REDIRECT_URL);
|
assertThat(registration.getRedirectUriTemplate()).isEqualTo(DEFAULT_LOGIN_REDIRECT_URL);
|
||||||
assertThat(registration.getScopes()).containsOnly("openid", "profile", "email",
|
assertThat(registration.getScopes()).containsOnly("openid", "profile", "email",
|
||||||
"address", "phone");
|
"address", "phone");
|
||||||
assertThat(registration.getClientName()).isEqualTo("Google");
|
assertThat(registration.getClientName()).isEqualTo("Google");
|
||||||
|
@ -75,7 +75,7 @@ public class CommonOAuth2ProviderTests {
|
||||||
.isEqualTo(ClientAuthenticationMethod.BASIC);
|
.isEqualTo(ClientAuthenticationMethod.BASIC);
|
||||||
assertThat(registration.getAuthorizationGrantType())
|
assertThat(registration.getAuthorizationGrantType())
|
||||||
.isEqualTo(AuthorizationGrantType.AUTHORIZATION_CODE);
|
.isEqualTo(AuthorizationGrantType.AUTHORIZATION_CODE);
|
||||||
assertThat(registration.getRedirectUri()).isEqualTo(DEFAULT_LOGIN_REDIRECT_URL);
|
assertThat(registration.getRedirectUriTemplate()).isEqualTo(DEFAULT_LOGIN_REDIRECT_URL);
|
||||||
assertThat(registration.getScopes()).containsOnly("user");
|
assertThat(registration.getScopes()).containsOnly("user");
|
||||||
assertThat(registration.getClientName()).isEqualTo("GitHub");
|
assertThat(registration.getClientName()).isEqualTo("GitHub");
|
||||||
assertThat(registration.getRegistrationId()).isEqualTo("123");
|
assertThat(registration.getRegistrationId()).isEqualTo("123");
|
||||||
|
@ -98,7 +98,7 @@ public class CommonOAuth2ProviderTests {
|
||||||
.isEqualTo(ClientAuthenticationMethod.POST);
|
.isEqualTo(ClientAuthenticationMethod.POST);
|
||||||
assertThat(registration.getAuthorizationGrantType())
|
assertThat(registration.getAuthorizationGrantType())
|
||||||
.isEqualTo(AuthorizationGrantType.AUTHORIZATION_CODE);
|
.isEqualTo(AuthorizationGrantType.AUTHORIZATION_CODE);
|
||||||
assertThat(registration.getRedirectUri()).isEqualTo(DEFAULT_LOGIN_REDIRECT_URL);
|
assertThat(registration.getRedirectUriTemplate()).isEqualTo(DEFAULT_LOGIN_REDIRECT_URL);
|
||||||
assertThat(registration.getScopes()).containsOnly("public_profile", "email");
|
assertThat(registration.getScopes()).containsOnly("public_profile", "email");
|
||||||
assertThat(registration.getClientName()).isEqualTo("Facebook");
|
assertThat(registration.getClientName()).isEqualTo("Facebook");
|
||||||
assertThat(registration.getRegistrationId()).isEqualTo("123");
|
assertThat(registration.getRegistrationId()).isEqualTo("123");
|
||||||
|
@ -123,7 +123,7 @@ public class CommonOAuth2ProviderTests {
|
||||||
.isEqualTo(ClientAuthenticationMethod.BASIC);
|
.isEqualTo(ClientAuthenticationMethod.BASIC);
|
||||||
assertThat(registration.getAuthorizationGrantType())
|
assertThat(registration.getAuthorizationGrantType())
|
||||||
.isEqualTo(AuthorizationGrantType.AUTHORIZATION_CODE);
|
.isEqualTo(AuthorizationGrantType.AUTHORIZATION_CODE);
|
||||||
assertThat(registration.getRedirectUri()).isEqualTo(DEFAULT_LOGIN_REDIRECT_URL);
|
assertThat(registration.getRedirectUriTemplate()).isEqualTo(DEFAULT_LOGIN_REDIRECT_URL);
|
||||||
assertThat(registration.getScopes()).containsOnly("openid", "profile", "email",
|
assertThat(registration.getScopes()).containsOnly("openid", "profile", "email",
|
||||||
"address", "phone");
|
"address", "phone");
|
||||||
assertThat(registration.getClientName()).isEqualTo("Okta");
|
assertThat(registration.getClientName()).isEqualTo("Okta");
|
||||||
|
|
|
@ -38,7 +38,7 @@ public final class ClientRegistration {
|
||||||
private String clientSecret;
|
private String clientSecret;
|
||||||
private ClientAuthenticationMethod clientAuthenticationMethod = ClientAuthenticationMethod.BASIC;
|
private ClientAuthenticationMethod clientAuthenticationMethod = ClientAuthenticationMethod.BASIC;
|
||||||
private AuthorizationGrantType authorizationGrantType;
|
private AuthorizationGrantType authorizationGrantType;
|
||||||
private String redirectUri;
|
private String redirectUriTemplate;
|
||||||
private Set<String> scopes = Collections.emptySet();
|
private Set<String> scopes = Collections.emptySet();
|
||||||
private ProviderDetails providerDetails = new ProviderDetails();
|
private ProviderDetails providerDetails = new ProviderDetails();
|
||||||
private String clientName;
|
private String clientName;
|
||||||
|
@ -66,8 +66,8 @@ public final class ClientRegistration {
|
||||||
return this.authorizationGrantType;
|
return this.authorizationGrantType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getRedirectUri() {
|
public String getRedirectUriTemplate() {
|
||||||
return this.redirectUri;
|
return this.redirectUriTemplate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<String> getScopes() {
|
public Set<String> getScopes() {
|
||||||
|
@ -90,7 +90,7 @@ public final class ClientRegistration {
|
||||||
+ ", clientSecret='" + this.clientSecret + '\''
|
+ ", clientSecret='" + this.clientSecret + '\''
|
||||||
+ ", clientAuthenticationMethod=" + this.clientAuthenticationMethod
|
+ ", clientAuthenticationMethod=" + this.clientAuthenticationMethod
|
||||||
+ ", authorizationGrantType=" + this.authorizationGrantType
|
+ ", authorizationGrantType=" + this.authorizationGrantType
|
||||||
+ ", redirectUri='" + this.redirectUri + '\''
|
+ ", redirectUriTemplate='" + this.redirectUriTemplate + '\''
|
||||||
+ ", scopes=" + this.scopes
|
+ ", scopes=" + this.scopes
|
||||||
+ ", providerDetails=" + this.providerDetails
|
+ ", providerDetails=" + this.providerDetails
|
||||||
+ ", clientName='" + this.clientName
|
+ ", clientName='" + this.clientName
|
||||||
|
@ -150,7 +150,7 @@ public final class ClientRegistration {
|
||||||
private String clientSecret;
|
private String clientSecret;
|
||||||
private ClientAuthenticationMethod clientAuthenticationMethod = ClientAuthenticationMethod.BASIC;
|
private ClientAuthenticationMethod clientAuthenticationMethod = ClientAuthenticationMethod.BASIC;
|
||||||
private AuthorizationGrantType authorizationGrantType;
|
private AuthorizationGrantType authorizationGrantType;
|
||||||
private String redirectUri;
|
private String redirectUriTemplate;
|
||||||
private Set<String> scopes;
|
private Set<String> scopes;
|
||||||
private String authorizationUri;
|
private String authorizationUri;
|
||||||
private String tokenUri;
|
private String tokenUri;
|
||||||
|
@ -183,8 +183,8 @@ public final class ClientRegistration {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder redirectUri(String redirectUri) {
|
public Builder redirectUriTemplate(String redirectUriTemplate) {
|
||||||
this.redirectUri = redirectUri;
|
this.redirectUriTemplate = redirectUriTemplate;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -244,7 +244,7 @@ public final class ClientRegistration {
|
||||||
clientRegistration.clientSecret = this.clientSecret;
|
clientRegistration.clientSecret = this.clientSecret;
|
||||||
clientRegistration.clientAuthenticationMethod = this.clientAuthenticationMethod;
|
clientRegistration.clientAuthenticationMethod = this.clientAuthenticationMethod;
|
||||||
clientRegistration.authorizationGrantType = this.authorizationGrantType;
|
clientRegistration.authorizationGrantType = this.authorizationGrantType;
|
||||||
clientRegistration.redirectUri = this.redirectUri;
|
clientRegistration.redirectUriTemplate = this.redirectUriTemplate;
|
||||||
clientRegistration.scopes = this.scopes;
|
clientRegistration.scopes = this.scopes;
|
||||||
|
|
||||||
ProviderDetails providerDetails = clientRegistration.new ProviderDetails();
|
ProviderDetails providerDetails = clientRegistration.new ProviderDetails();
|
||||||
|
@ -267,7 +267,7 @@ public final class ClientRegistration {
|
||||||
Assert.hasText(this.clientId, "clientId cannot be empty");
|
Assert.hasText(this.clientId, "clientId cannot be empty");
|
||||||
Assert.hasText(this.clientSecret, "clientSecret cannot be empty");
|
Assert.hasText(this.clientSecret, "clientSecret cannot be empty");
|
||||||
Assert.notNull(this.clientAuthenticationMethod, "clientAuthenticationMethod cannot be null");
|
Assert.notNull(this.clientAuthenticationMethod, "clientAuthenticationMethod cannot be null");
|
||||||
Assert.hasText(this.redirectUri, "redirectUri cannot be empty");
|
Assert.hasText(this.redirectUriTemplate, "redirectUriTemplate cannot be empty");
|
||||||
Assert.notEmpty(this.scopes, "scopes cannot be empty");
|
Assert.notEmpty(this.scopes, "scopes cannot be empty");
|
||||||
Assert.hasText(this.authorizationUri, "authorizationUri cannot be empty");
|
Assert.hasText(this.authorizationUri, "authorizationUri cannot be empty");
|
||||||
Assert.hasText(this.tokenUri, "tokenUri cannot be empty");
|
Assert.hasText(this.tokenUri, "tokenUri cannot be empty");
|
||||||
|
@ -283,7 +283,7 @@ public final class ClientRegistration {
|
||||||
"authorizationGrantType must be " + AuthorizationGrantType.IMPLICIT.getValue());
|
"authorizationGrantType must be " + AuthorizationGrantType.IMPLICIT.getValue());
|
||||||
Assert.hasText(this.registrationId, "registrationId cannot be empty");
|
Assert.hasText(this.registrationId, "registrationId cannot be empty");
|
||||||
Assert.hasText(this.clientId, "clientId cannot be empty");
|
Assert.hasText(this.clientId, "clientId cannot be empty");
|
||||||
Assert.hasText(this.redirectUri, "redirectUri cannot be empty");
|
Assert.hasText(this.redirectUriTemplate, "redirectUriTemplate cannot be empty");
|
||||||
Assert.notEmpty(this.scopes, "scopes cannot be empty");
|
Assert.notEmpty(this.scopes, "scopes cannot be empty");
|
||||||
Assert.hasText(this.authorizationUri, "authorizationUri cannot be empty");
|
Assert.hasText(this.authorizationUri, "authorizationUri cannot be empty");
|
||||||
Assert.hasText(this.clientName, "clientName cannot be empty");
|
Assert.hasText(this.clientName, "clientName cannot be empty");
|
||||||
|
|
|
@ -180,7 +180,7 @@ public class OAuth2AuthorizationRequestRedirectFilter extends OncePerRequestFilt
|
||||||
.toUriString();
|
.toUriString();
|
||||||
uriVariables.put("baseUrl", baseUrl);
|
uriVariables.put("baseUrl", baseUrl);
|
||||||
|
|
||||||
return UriComponentsBuilder.fromUriString(clientRegistration.getRedirectUri())
|
return UriComponentsBuilder.fromUriString(clientRegistration.getRedirectUriTemplate())
|
||||||
.buildAndExpand(uriVariables)
|
.buildAndExpand(uriVariables)
|
||||||
.toUriString();
|
.toUriString();
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ public class InMemoryOAuth2AuthorizedClientServiceTests {
|
||||||
.clientSecret("secret")
|
.clientSecret("secret")
|
||||||
.clientAuthenticationMethod(ClientAuthenticationMethod.BASIC)
|
.clientAuthenticationMethod(ClientAuthenticationMethod.BASIC)
|
||||||
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE)
|
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE)
|
||||||
.redirectUri("{baseUrl}/login/oauth2/code/{registrationId}")
|
.redirectUriTemplate("{baseUrl}/login/oauth2/code/{registrationId}")
|
||||||
.scope("user")
|
.scope("user")
|
||||||
.authorizationUri("https://provider.com/oauth2/authorize")
|
.authorizationUri("https://provider.com/oauth2/authorize")
|
||||||
.tokenUri("https://provider.com/oauth2/token")
|
.tokenUri("https://provider.com/oauth2/token")
|
||||||
|
@ -59,7 +59,7 @@ public class InMemoryOAuth2AuthorizedClientServiceTests {
|
||||||
.clientSecret("secret")
|
.clientSecret("secret")
|
||||||
.clientAuthenticationMethod(ClientAuthenticationMethod.BASIC)
|
.clientAuthenticationMethod(ClientAuthenticationMethod.BASIC)
|
||||||
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE)
|
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE)
|
||||||
.redirectUri("{baseUrl}/login/oauth2/code/{registrationId}")
|
.redirectUriTemplate("{baseUrl}/login/oauth2/code/{registrationId}")
|
||||||
.scope("openid", "profile", "email")
|
.scope("openid", "profile", "email")
|
||||||
.authorizationUri("https://provider.com/oauth2/authorize")
|
.authorizationUri("https://provider.com/oauth2/authorize")
|
||||||
.tokenUri("https://provider.com/oauth2/token")
|
.tokenUri("https://provider.com/oauth2/token")
|
||||||
|
@ -73,7 +73,7 @@ public class InMemoryOAuth2AuthorizedClientServiceTests {
|
||||||
.clientSecret("secret")
|
.clientSecret("secret")
|
||||||
.clientAuthenticationMethod(ClientAuthenticationMethod.BASIC)
|
.clientAuthenticationMethod(ClientAuthenticationMethod.BASIC)
|
||||||
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE)
|
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE)
|
||||||
.redirectUri("{baseUrl}/login/oauth2/code/{registrationId}")
|
.redirectUriTemplate("{baseUrl}/login/oauth2/code/{registrationId}")
|
||||||
.scope("openid", "profile")
|
.scope("openid", "profile")
|
||||||
.authorizationUri("https://provider.com/oauth2/authorize")
|
.authorizationUri("https://provider.com/oauth2/authorize")
|
||||||
.tokenUri("https://provider.com/oauth2/token")
|
.tokenUri("https://provider.com/oauth2/token")
|
||||||
|
|
|
@ -125,7 +125,7 @@ public class NimbusAuthorizationCodeTokenResponseClientTests {
|
||||||
this.exception.expect(IllegalArgumentException.class);
|
this.exception.expect(IllegalArgumentException.class);
|
||||||
|
|
||||||
String redirectUri = "http:\\example.com";
|
String redirectUri = "http:\\example.com";
|
||||||
when(this.clientRegistration.getRedirectUri()).thenReturn(redirectUri);
|
when(this.clientRegistration.getRedirectUriTemplate()).thenReturn(redirectUri);
|
||||||
|
|
||||||
this.tokenResponseClient.getTokenResponse(
|
this.tokenResponseClient.getTokenResponse(
|
||||||
new OAuth2AuthorizationCodeGrantRequest(this.clientRegistration, this.authorizationExchange));
|
new OAuth2AuthorizationCodeGrantRequest(this.clientRegistration, this.authorizationExchange));
|
||||||
|
|
|
@ -48,7 +48,7 @@ public class ClientRegistrationTests {
|
||||||
.clientSecret(CLIENT_SECRET)
|
.clientSecret(CLIENT_SECRET)
|
||||||
.clientAuthenticationMethod(ClientAuthenticationMethod.BASIC)
|
.clientAuthenticationMethod(ClientAuthenticationMethod.BASIC)
|
||||||
.authorizationGrantType(null)
|
.authorizationGrantType(null)
|
||||||
.redirectUri(REDIRECT_URI)
|
.redirectUriTemplate(REDIRECT_URI)
|
||||||
.scope(SCOPES.toArray(new String[0]))
|
.scope(SCOPES.toArray(new String[0]))
|
||||||
.authorizationUri(AUTHORIZATION_URI)
|
.authorizationUri(AUTHORIZATION_URI)
|
||||||
.tokenUri(TOKEN_URI)
|
.tokenUri(TOKEN_URI)
|
||||||
|
@ -64,7 +64,7 @@ public class ClientRegistrationTests {
|
||||||
.clientSecret(CLIENT_SECRET)
|
.clientSecret(CLIENT_SECRET)
|
||||||
.clientAuthenticationMethod(ClientAuthenticationMethod.BASIC)
|
.clientAuthenticationMethod(ClientAuthenticationMethod.BASIC)
|
||||||
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE)
|
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE)
|
||||||
.redirectUri(REDIRECT_URI)
|
.redirectUriTemplate(REDIRECT_URI)
|
||||||
.scope(SCOPES.toArray(new String[0]))
|
.scope(SCOPES.toArray(new String[0]))
|
||||||
.authorizationUri(AUTHORIZATION_URI)
|
.authorizationUri(AUTHORIZATION_URI)
|
||||||
.tokenUri(TOKEN_URI)
|
.tokenUri(TOKEN_URI)
|
||||||
|
@ -77,7 +77,7 @@ public class ClientRegistrationTests {
|
||||||
assertThat(registration.getClientSecret()).isEqualTo(CLIENT_SECRET);
|
assertThat(registration.getClientSecret()).isEqualTo(CLIENT_SECRET);
|
||||||
assertThat(registration.getClientAuthenticationMethod()).isEqualTo(ClientAuthenticationMethod.BASIC);
|
assertThat(registration.getClientAuthenticationMethod()).isEqualTo(ClientAuthenticationMethod.BASIC);
|
||||||
assertThat(registration.getAuthorizationGrantType()).isEqualTo(AuthorizationGrantType.AUTHORIZATION_CODE);
|
assertThat(registration.getAuthorizationGrantType()).isEqualTo(AuthorizationGrantType.AUTHORIZATION_CODE);
|
||||||
assertThat(registration.getRedirectUri()).isEqualTo(REDIRECT_URI);
|
assertThat(registration.getRedirectUriTemplate()).isEqualTo(REDIRECT_URI);
|
||||||
assertThat(registration.getScopes()).isEqualTo(SCOPES);
|
assertThat(registration.getScopes()).isEqualTo(SCOPES);
|
||||||
assertThat(registration.getProviderDetails().getAuthorizationUri()).isEqualTo(AUTHORIZATION_URI);
|
assertThat(registration.getProviderDetails().getAuthorizationUri()).isEqualTo(AUTHORIZATION_URI);
|
||||||
assertThat(registration.getProviderDetails().getTokenUri()).isEqualTo(TOKEN_URI);
|
assertThat(registration.getProviderDetails().getTokenUri()).isEqualTo(TOKEN_URI);
|
||||||
|
@ -92,7 +92,7 @@ public class ClientRegistrationTests {
|
||||||
.clientSecret(CLIENT_SECRET)
|
.clientSecret(CLIENT_SECRET)
|
||||||
.clientAuthenticationMethod(ClientAuthenticationMethod.BASIC)
|
.clientAuthenticationMethod(ClientAuthenticationMethod.BASIC)
|
||||||
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE)
|
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE)
|
||||||
.redirectUri(REDIRECT_URI)
|
.redirectUriTemplate(REDIRECT_URI)
|
||||||
.scope(SCOPES.toArray(new String[0]))
|
.scope(SCOPES.toArray(new String[0]))
|
||||||
.authorizationUri(AUTHORIZATION_URI)
|
.authorizationUri(AUTHORIZATION_URI)
|
||||||
.tokenUri(TOKEN_URI)
|
.tokenUri(TOKEN_URI)
|
||||||
|
@ -108,7 +108,7 @@ public class ClientRegistrationTests {
|
||||||
.clientSecret(CLIENT_SECRET)
|
.clientSecret(CLIENT_SECRET)
|
||||||
.clientAuthenticationMethod(ClientAuthenticationMethod.BASIC)
|
.clientAuthenticationMethod(ClientAuthenticationMethod.BASIC)
|
||||||
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE)
|
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE)
|
||||||
.redirectUri(REDIRECT_URI)
|
.redirectUriTemplate(REDIRECT_URI)
|
||||||
.scope(SCOPES.toArray(new String[0]))
|
.scope(SCOPES.toArray(new String[0]))
|
||||||
.authorizationUri(AUTHORIZATION_URI)
|
.authorizationUri(AUTHORIZATION_URI)
|
||||||
.tokenUri(TOKEN_URI)
|
.tokenUri(TOKEN_URI)
|
||||||
|
@ -124,7 +124,7 @@ public class ClientRegistrationTests {
|
||||||
.clientSecret(null)
|
.clientSecret(null)
|
||||||
.clientAuthenticationMethod(ClientAuthenticationMethod.BASIC)
|
.clientAuthenticationMethod(ClientAuthenticationMethod.BASIC)
|
||||||
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE)
|
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE)
|
||||||
.redirectUri(REDIRECT_URI)
|
.redirectUriTemplate(REDIRECT_URI)
|
||||||
.scope(SCOPES.toArray(new String[0]))
|
.scope(SCOPES.toArray(new String[0]))
|
||||||
.authorizationUri(AUTHORIZATION_URI)
|
.authorizationUri(AUTHORIZATION_URI)
|
||||||
.tokenUri(TOKEN_URI)
|
.tokenUri(TOKEN_URI)
|
||||||
|
@ -140,7 +140,7 @@ public class ClientRegistrationTests {
|
||||||
.clientSecret(CLIENT_SECRET)
|
.clientSecret(CLIENT_SECRET)
|
||||||
.clientAuthenticationMethod(null)
|
.clientAuthenticationMethod(null)
|
||||||
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE)
|
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE)
|
||||||
.redirectUri(REDIRECT_URI)
|
.redirectUriTemplate(REDIRECT_URI)
|
||||||
.scope(SCOPES.toArray(new String[0]))
|
.scope(SCOPES.toArray(new String[0]))
|
||||||
.authorizationUri(AUTHORIZATION_URI)
|
.authorizationUri(AUTHORIZATION_URI)
|
||||||
.tokenUri(TOKEN_URI)
|
.tokenUri(TOKEN_URI)
|
||||||
|
@ -156,7 +156,7 @@ public class ClientRegistrationTests {
|
||||||
.clientSecret(CLIENT_SECRET)
|
.clientSecret(CLIENT_SECRET)
|
||||||
.clientAuthenticationMethod(ClientAuthenticationMethod.BASIC)
|
.clientAuthenticationMethod(ClientAuthenticationMethod.BASIC)
|
||||||
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE)
|
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE)
|
||||||
.redirectUri(null)
|
.redirectUriTemplate(null)
|
||||||
.scope(SCOPES.toArray(new String[0]))
|
.scope(SCOPES.toArray(new String[0]))
|
||||||
.authorizationUri(AUTHORIZATION_URI)
|
.authorizationUri(AUTHORIZATION_URI)
|
||||||
.tokenUri(TOKEN_URI)
|
.tokenUri(TOKEN_URI)
|
||||||
|
@ -172,7 +172,7 @@ public class ClientRegistrationTests {
|
||||||
.clientSecret(CLIENT_SECRET)
|
.clientSecret(CLIENT_SECRET)
|
||||||
.clientAuthenticationMethod(ClientAuthenticationMethod.BASIC)
|
.clientAuthenticationMethod(ClientAuthenticationMethod.BASIC)
|
||||||
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE)
|
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE)
|
||||||
.redirectUri(REDIRECT_URI)
|
.redirectUriTemplate(REDIRECT_URI)
|
||||||
.scope(null)
|
.scope(null)
|
||||||
.authorizationUri(AUTHORIZATION_URI)
|
.authorizationUri(AUTHORIZATION_URI)
|
||||||
.tokenUri(TOKEN_URI)
|
.tokenUri(TOKEN_URI)
|
||||||
|
@ -188,7 +188,7 @@ public class ClientRegistrationTests {
|
||||||
.clientSecret(CLIENT_SECRET)
|
.clientSecret(CLIENT_SECRET)
|
||||||
.clientAuthenticationMethod(ClientAuthenticationMethod.BASIC)
|
.clientAuthenticationMethod(ClientAuthenticationMethod.BASIC)
|
||||||
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE)
|
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE)
|
||||||
.redirectUri(REDIRECT_URI)
|
.redirectUriTemplate(REDIRECT_URI)
|
||||||
.scope(SCOPES.toArray(new String[0]))
|
.scope(SCOPES.toArray(new String[0]))
|
||||||
.authorizationUri(null)
|
.authorizationUri(null)
|
||||||
.tokenUri(TOKEN_URI)
|
.tokenUri(TOKEN_URI)
|
||||||
|
@ -204,7 +204,7 @@ public class ClientRegistrationTests {
|
||||||
.clientSecret(CLIENT_SECRET)
|
.clientSecret(CLIENT_SECRET)
|
||||||
.clientAuthenticationMethod(ClientAuthenticationMethod.BASIC)
|
.clientAuthenticationMethod(ClientAuthenticationMethod.BASIC)
|
||||||
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE)
|
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE)
|
||||||
.redirectUri(REDIRECT_URI)
|
.redirectUriTemplate(REDIRECT_URI)
|
||||||
.scope(SCOPES.toArray(new String[0]))
|
.scope(SCOPES.toArray(new String[0]))
|
||||||
.authorizationUri(AUTHORIZATION_URI)
|
.authorizationUri(AUTHORIZATION_URI)
|
||||||
.tokenUri(null)
|
.tokenUri(null)
|
||||||
|
@ -220,7 +220,7 @@ public class ClientRegistrationTests {
|
||||||
.clientSecret(CLIENT_SECRET)
|
.clientSecret(CLIENT_SECRET)
|
||||||
.clientAuthenticationMethod(ClientAuthenticationMethod.BASIC)
|
.clientAuthenticationMethod(ClientAuthenticationMethod.BASIC)
|
||||||
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE)
|
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE)
|
||||||
.redirectUri(REDIRECT_URI)
|
.redirectUriTemplate(REDIRECT_URI)
|
||||||
.scope(SCOPES.toArray(new String[0]))
|
.scope(SCOPES.toArray(new String[0]))
|
||||||
.authorizationUri(AUTHORIZATION_URI)
|
.authorizationUri(AUTHORIZATION_URI)
|
||||||
.tokenUri(TOKEN_URI)
|
.tokenUri(TOKEN_URI)
|
||||||
|
@ -236,7 +236,7 @@ public class ClientRegistrationTests {
|
||||||
.clientSecret(CLIENT_SECRET)
|
.clientSecret(CLIENT_SECRET)
|
||||||
.clientAuthenticationMethod(ClientAuthenticationMethod.BASIC)
|
.clientAuthenticationMethod(ClientAuthenticationMethod.BASIC)
|
||||||
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE)
|
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE)
|
||||||
.redirectUri(REDIRECT_URI)
|
.redirectUriTemplate(REDIRECT_URI)
|
||||||
.scope(SCOPES.toArray(new String[0]))
|
.scope(SCOPES.toArray(new String[0]))
|
||||||
.authorizationUri(AUTHORIZATION_URI)
|
.authorizationUri(AUTHORIZATION_URI)
|
||||||
.tokenUri(TOKEN_URI)
|
.tokenUri(TOKEN_URI)
|
||||||
|
@ -252,7 +252,7 @@ public class ClientRegistrationTests {
|
||||||
.clientSecret(CLIENT_SECRET)
|
.clientSecret(CLIENT_SECRET)
|
||||||
.clientAuthenticationMethod(ClientAuthenticationMethod.BASIC)
|
.clientAuthenticationMethod(ClientAuthenticationMethod.BASIC)
|
||||||
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE)
|
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE)
|
||||||
.redirectUri(REDIRECT_URI)
|
.redirectUriTemplate(REDIRECT_URI)
|
||||||
.scope("scope1")
|
.scope("scope1")
|
||||||
.authorizationUri(AUTHORIZATION_URI)
|
.authorizationUri(AUTHORIZATION_URI)
|
||||||
.tokenUri(TOKEN_URI)
|
.tokenUri(TOKEN_URI)
|
||||||
|
@ -265,7 +265,7 @@ public class ClientRegistrationTests {
|
||||||
ClientRegistration registration = ClientRegistration.withRegistrationId(REGISTRATION_ID)
|
ClientRegistration registration = ClientRegistration.withRegistrationId(REGISTRATION_ID)
|
||||||
.clientId(CLIENT_ID)
|
.clientId(CLIENT_ID)
|
||||||
.authorizationGrantType(AuthorizationGrantType.IMPLICIT)
|
.authorizationGrantType(AuthorizationGrantType.IMPLICIT)
|
||||||
.redirectUri(REDIRECT_URI)
|
.redirectUriTemplate(REDIRECT_URI)
|
||||||
.scope(SCOPES.toArray(new String[0]))
|
.scope(SCOPES.toArray(new String[0]))
|
||||||
.authorizationUri(AUTHORIZATION_URI)
|
.authorizationUri(AUTHORIZATION_URI)
|
||||||
.clientName(CLIENT_NAME)
|
.clientName(CLIENT_NAME)
|
||||||
|
@ -274,7 +274,7 @@ public class ClientRegistrationTests {
|
||||||
assertThat(registration.getRegistrationId()).isEqualTo(REGISTRATION_ID);
|
assertThat(registration.getRegistrationId()).isEqualTo(REGISTRATION_ID);
|
||||||
assertThat(registration.getClientId()).isEqualTo(CLIENT_ID);
|
assertThat(registration.getClientId()).isEqualTo(CLIENT_ID);
|
||||||
assertThat(registration.getAuthorizationGrantType()).isEqualTo(AuthorizationGrantType.IMPLICIT);
|
assertThat(registration.getAuthorizationGrantType()).isEqualTo(AuthorizationGrantType.IMPLICIT);
|
||||||
assertThat(registration.getRedirectUri()).isEqualTo(REDIRECT_URI);
|
assertThat(registration.getRedirectUriTemplate()).isEqualTo(REDIRECT_URI);
|
||||||
assertThat(registration.getScopes()).isEqualTo(SCOPES);
|
assertThat(registration.getScopes()).isEqualTo(SCOPES);
|
||||||
assertThat(registration.getProviderDetails().getAuthorizationUri()).isEqualTo(AUTHORIZATION_URI);
|
assertThat(registration.getProviderDetails().getAuthorizationUri()).isEqualTo(AUTHORIZATION_URI);
|
||||||
assertThat(registration.getClientName()).isEqualTo(CLIENT_NAME);
|
assertThat(registration.getClientName()).isEqualTo(CLIENT_NAME);
|
||||||
|
@ -285,7 +285,7 @@ public class ClientRegistrationTests {
|
||||||
ClientRegistration.withRegistrationId(null)
|
ClientRegistration.withRegistrationId(null)
|
||||||
.clientId(CLIENT_ID)
|
.clientId(CLIENT_ID)
|
||||||
.authorizationGrantType(AuthorizationGrantType.IMPLICIT)
|
.authorizationGrantType(AuthorizationGrantType.IMPLICIT)
|
||||||
.redirectUri(REDIRECT_URI)
|
.redirectUriTemplate(REDIRECT_URI)
|
||||||
.scope(SCOPES.toArray(new String[0]))
|
.scope(SCOPES.toArray(new String[0]))
|
||||||
.authorizationUri(AUTHORIZATION_URI)
|
.authorizationUri(AUTHORIZATION_URI)
|
||||||
.clientName(CLIENT_NAME)
|
.clientName(CLIENT_NAME)
|
||||||
|
@ -297,7 +297,7 @@ public class ClientRegistrationTests {
|
||||||
ClientRegistration.withRegistrationId(REGISTRATION_ID)
|
ClientRegistration.withRegistrationId(REGISTRATION_ID)
|
||||||
.clientId(null)
|
.clientId(null)
|
||||||
.authorizationGrantType(AuthorizationGrantType.IMPLICIT)
|
.authorizationGrantType(AuthorizationGrantType.IMPLICIT)
|
||||||
.redirectUri(REDIRECT_URI)
|
.redirectUriTemplate(REDIRECT_URI)
|
||||||
.scope(SCOPES.toArray(new String[0]))
|
.scope(SCOPES.toArray(new String[0]))
|
||||||
.authorizationUri(AUTHORIZATION_URI)
|
.authorizationUri(AUTHORIZATION_URI)
|
||||||
.clientName(CLIENT_NAME)
|
.clientName(CLIENT_NAME)
|
||||||
|
@ -309,7 +309,7 @@ public class ClientRegistrationTests {
|
||||||
ClientRegistration.withRegistrationId(REGISTRATION_ID)
|
ClientRegistration.withRegistrationId(REGISTRATION_ID)
|
||||||
.clientId(CLIENT_ID)
|
.clientId(CLIENT_ID)
|
||||||
.authorizationGrantType(AuthorizationGrantType.IMPLICIT)
|
.authorizationGrantType(AuthorizationGrantType.IMPLICIT)
|
||||||
.redirectUri(null)
|
.redirectUriTemplate(null)
|
||||||
.scope(SCOPES.toArray(new String[0]))
|
.scope(SCOPES.toArray(new String[0]))
|
||||||
.authorizationUri(AUTHORIZATION_URI)
|
.authorizationUri(AUTHORIZATION_URI)
|
||||||
.clientName(CLIENT_NAME)
|
.clientName(CLIENT_NAME)
|
||||||
|
@ -321,7 +321,7 @@ public class ClientRegistrationTests {
|
||||||
ClientRegistration.withRegistrationId(REGISTRATION_ID)
|
ClientRegistration.withRegistrationId(REGISTRATION_ID)
|
||||||
.clientId(CLIENT_ID)
|
.clientId(CLIENT_ID)
|
||||||
.authorizationGrantType(AuthorizationGrantType.IMPLICIT)
|
.authorizationGrantType(AuthorizationGrantType.IMPLICIT)
|
||||||
.redirectUri(REDIRECT_URI)
|
.redirectUriTemplate(REDIRECT_URI)
|
||||||
.scope(null)
|
.scope(null)
|
||||||
.authorizationUri(AUTHORIZATION_URI)
|
.authorizationUri(AUTHORIZATION_URI)
|
||||||
.clientName(CLIENT_NAME)
|
.clientName(CLIENT_NAME)
|
||||||
|
@ -333,7 +333,7 @@ public class ClientRegistrationTests {
|
||||||
ClientRegistration.withRegistrationId(REGISTRATION_ID)
|
ClientRegistration.withRegistrationId(REGISTRATION_ID)
|
||||||
.clientId(CLIENT_ID)
|
.clientId(CLIENT_ID)
|
||||||
.authorizationGrantType(AuthorizationGrantType.IMPLICIT)
|
.authorizationGrantType(AuthorizationGrantType.IMPLICIT)
|
||||||
.redirectUri(REDIRECT_URI)
|
.redirectUriTemplate(REDIRECT_URI)
|
||||||
.scope(SCOPES.toArray(new String[0]))
|
.scope(SCOPES.toArray(new String[0]))
|
||||||
.authorizationUri(null)
|
.authorizationUri(null)
|
||||||
.clientName(CLIENT_NAME)
|
.clientName(CLIENT_NAME)
|
||||||
|
@ -345,7 +345,7 @@ public class ClientRegistrationTests {
|
||||||
ClientRegistration.withRegistrationId(REGISTRATION_ID)
|
ClientRegistration.withRegistrationId(REGISTRATION_ID)
|
||||||
.clientId(CLIENT_ID)
|
.clientId(CLIENT_ID)
|
||||||
.authorizationGrantType(AuthorizationGrantType.IMPLICIT)
|
.authorizationGrantType(AuthorizationGrantType.IMPLICIT)
|
||||||
.redirectUri(REDIRECT_URI)
|
.redirectUriTemplate(REDIRECT_URI)
|
||||||
.scope(SCOPES.toArray(new String[0]))
|
.scope(SCOPES.toArray(new String[0]))
|
||||||
.authorizationUri(AUTHORIZATION_URI)
|
.authorizationUri(AUTHORIZATION_URI)
|
||||||
.clientName(null)
|
.clientName(null)
|
||||||
|
|
|
@ -40,7 +40,7 @@ public class InMemoryClientRegistrationRepositoryTests {
|
||||||
.clientId("client-id")
|
.clientId("client-id")
|
||||||
.clientName("client-name")
|
.clientName("client-name")
|
||||||
.clientSecret("client-secret")
|
.clientSecret("client-secret")
|
||||||
.redirectUri("{baseUrl}/login/oauth2/code/{registrationId}")
|
.redirectUriTemplate("{baseUrl}/login/oauth2/code/{registrationId}")
|
||||||
.scope("user")
|
.scope("user")
|
||||||
.tokenUri("https://example.com/oauth/access_token")
|
.tokenUri("https://example.com/oauth/access_token")
|
||||||
.build();
|
.build();
|
||||||
|
|
|
@ -56,7 +56,7 @@ public class OAuth2AuthorizationRequestRedirectFilterTests {
|
||||||
.clientSecret("secret")
|
.clientSecret("secret")
|
||||||
.clientAuthenticationMethod(ClientAuthenticationMethod.BASIC)
|
.clientAuthenticationMethod(ClientAuthenticationMethod.BASIC)
|
||||||
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE)
|
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE)
|
||||||
.redirectUri("{baseUrl}/login/oauth2/code/{registrationId}")
|
.redirectUriTemplate("{baseUrl}/login/oauth2/code/{registrationId}")
|
||||||
.scope("user")
|
.scope("user")
|
||||||
.authorizationUri("https://provider.com/oauth2/authorize")
|
.authorizationUri("https://provider.com/oauth2/authorize")
|
||||||
.tokenUri("https://provider.com/oauth2/token")
|
.tokenUri("https://provider.com/oauth2/token")
|
||||||
|
@ -69,7 +69,7 @@ public class OAuth2AuthorizationRequestRedirectFilterTests {
|
||||||
.clientSecret("secret")
|
.clientSecret("secret")
|
||||||
.clientAuthenticationMethod(ClientAuthenticationMethod.BASIC)
|
.clientAuthenticationMethod(ClientAuthenticationMethod.BASIC)
|
||||||
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE)
|
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE)
|
||||||
.redirectUri("{baseUrl}/login/oauth2/code/{registrationId}")
|
.redirectUriTemplate("{baseUrl}/login/oauth2/code/{registrationId}")
|
||||||
.scope("openid", "profile", "email")
|
.scope("openid", "profile", "email")
|
||||||
.authorizationUri("https://provider.com/oauth2/authorize")
|
.authorizationUri("https://provider.com/oauth2/authorize")
|
||||||
.tokenUri("https://provider.com/oauth2/token")
|
.tokenUri("https://provider.com/oauth2/token")
|
||||||
|
@ -80,7 +80,7 @@ public class OAuth2AuthorizationRequestRedirectFilterTests {
|
||||||
this.registration3 = ClientRegistration.withRegistrationId("registration-3")
|
this.registration3 = ClientRegistration.withRegistrationId("registration-3")
|
||||||
.clientId("client-3")
|
.clientId("client-3")
|
||||||
.authorizationGrantType(AuthorizationGrantType.IMPLICIT)
|
.authorizationGrantType(AuthorizationGrantType.IMPLICIT)
|
||||||
.redirectUri("{baseUrl}/login/oauth2/implicit/{registrationId}")
|
.redirectUriTemplate("{baseUrl}/login/oauth2/implicit/{registrationId}")
|
||||||
.scope("openid", "profile", "email")
|
.scope("openid", "profile", "email")
|
||||||
.authorizationUri("https://provider.com/oauth2/authorize")
|
.authorizationUri("https://provider.com/oauth2/authorize")
|
||||||
.tokenUri("https://provider.com/oauth2/token")
|
.tokenUri("https://provider.com/oauth2/token")
|
||||||
|
@ -266,7 +266,7 @@ public class OAuth2AuthorizationRequestRedirectFilterTests {
|
||||||
OAuth2AuthorizationRequest authorizationRequest = authorizationRequestRepository.loadAuthorizationRequest(request);
|
OAuth2AuthorizationRequest authorizationRequest = authorizationRequestRepository.loadAuthorizationRequest(request);
|
||||||
|
|
||||||
assertThat(authorizationRequest.getRedirectUri()).isNotEqualTo(
|
assertThat(authorizationRequest.getRedirectUri()).isNotEqualTo(
|
||||||
this.registration2.getRedirectUri());
|
this.registration2.getRedirectUriTemplate());
|
||||||
assertThat(authorizationRequest.getRedirectUri()).isEqualTo(
|
assertThat(authorizationRequest.getRedirectUri()).isEqualTo(
|
||||||
"http://localhost:80/login/oauth2/code/registration-2");
|
"http://localhost:80/login/oauth2/code/registration-2");
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,7 +82,7 @@ public class OAuth2LoginAuthenticationFilterTests {
|
||||||
.clientSecret("secret")
|
.clientSecret("secret")
|
||||||
.clientAuthenticationMethod(ClientAuthenticationMethod.BASIC)
|
.clientAuthenticationMethod(ClientAuthenticationMethod.BASIC)
|
||||||
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE)
|
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE)
|
||||||
.redirectUri("{baseUrl}/login/oauth2/code/{registrationId}")
|
.redirectUriTemplate("{baseUrl}/login/oauth2/code/{registrationId}")
|
||||||
.scope("user")
|
.scope("user")
|
||||||
.authorizationUri("https://provider.com/oauth2/authorize")
|
.authorizationUri("https://provider.com/oauth2/authorize")
|
||||||
.tokenUri("https://provider.com/oauth2/token")
|
.tokenUri("https://provider.com/oauth2/token")
|
||||||
|
@ -95,7 +95,7 @@ public class OAuth2LoginAuthenticationFilterTests {
|
||||||
.clientSecret("secret")
|
.clientSecret("secret")
|
||||||
.clientAuthenticationMethod(ClientAuthenticationMethod.BASIC)
|
.clientAuthenticationMethod(ClientAuthenticationMethod.BASIC)
|
||||||
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE)
|
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE)
|
||||||
.redirectUri("{baseUrl}/login/oauth2/code/{registrationId}")
|
.redirectUriTemplate("{baseUrl}/login/oauth2/code/{registrationId}")
|
||||||
.scope("openid", "profile", "email")
|
.scope("openid", "profile", "email")
|
||||||
.authorizationUri("https://provider.com/oauth2/authorize")
|
.authorizationUri("https://provider.com/oauth2/authorize")
|
||||||
.tokenUri("https://provider.com/oauth2/token")
|
.tokenUri("https://provider.com/oauth2/token")
|
||||||
|
|
Loading…
Reference in New Issue