Do not remove trailing slash from OAuth2 Issuer URI

Fixes gh-15324
pull/15487/head
Madhura Bhave 6 years ago
parent d05ae40c99
commit 3cc441c83e

@ -86,9 +86,7 @@ public final class OAuth2ClientPropertiesRegistrationAdapter {
Provider provider = providers.get(providerId);
String issuer = provider.getIssuerUri();
if (issuer != null) {
String cleanedIssuer = cleanIssuerPath(issuer);
Builder builder = ClientRegistrations
.fromOidcIssuerLocation(cleanedIssuer)
Builder builder = ClientRegistrations.fromOidcIssuerLocation(issuer)
.registrationId(registrationId);
return getBuilder(builder, provider);
}
@ -96,13 +94,6 @@ public final class OAuth2ClientPropertiesRegistrationAdapter {
return null;
}
private static String cleanIssuerPath(String issuer) {
if (issuer.endsWith("/")) {
return issuer.substring(0, issuer.length() - 1);
}
return issuer;
}
private static Builder getBuilder(String registrationId, String configuredProviderId,
Map<String, Provider> providers) {
String providerId = (configuredProviderId != null) ? configuredProviderId

@ -269,8 +269,7 @@ public class OAuth2ClientPropertiesRegistrationAdapterTests {
this.server = new MockWebServer();
this.server.start();
String issuer = this.server.url("").toString();
String cleanIssuerPath = cleanIssuerPath(issuer);
setupMockResponse(cleanIssuerPath);
setupMockResponse(issuer);
OAuth2ClientProperties.Registration registration = new OAuth2ClientProperties.Registration();
registration.setProvider("okta-oidc");
registration.setClientId("clientId");
@ -297,7 +296,7 @@ public class OAuth2ClientPropertiesRegistrationAdapterTests {
assertThat(adapted.getAuthorizationGrantType())
.isEqualTo(AuthorizationGrantType.AUTHORIZATION_CODE);
assertThat(adapted.getRegistrationId()).isEqualTo("okta");
assertThat(adapted.getClientName()).isEqualTo(cleanIssuerPath);
assertThat(adapted.getClientName()).isEqualTo(issuer);
assertThat(adapted.getScopes()).containsOnly("user");
assertThat(adapted.getRedirectUriTemplate())
.isEqualTo("http://example.com/redirect");
@ -316,8 +315,7 @@ public class OAuth2ClientPropertiesRegistrationAdapterTests {
this.server = new MockWebServer();
this.server.start();
String issuer = this.server.url("").toString();
String cleanIssuerPath = cleanIssuerPath(issuer);
setupMockResponse(cleanIssuerPath);
setupMockResponse(issuer);
OAuth2ClientProperties properties = new OAuth2ClientProperties();
Provider provider = new Provider();
provider.setIssuerUri(issuer);
@ -332,7 +330,7 @@ public class OAuth2ClientPropertiesRegistrationAdapterTests {
assertThat(adapted.getAuthorizationGrantType())
.isEqualTo(AuthorizationGrantType.AUTHORIZATION_CODE);
assertThat(adapted.getRegistrationId()).isEqualTo("okta");
assertThat(adapted.getClientName()).isEqualTo(cleanIssuerPath);
assertThat(adapted.getClientName()).isEqualTo(issuer);
assertThat(adapted.getScopes()).containsOnly("openid");
assertThat(providerDetails.getAuthorizationUri())
.isEqualTo("https://example.com/o/oauth2/v2/auth");

@ -29,4 +29,4 @@ spring:
client-name: GitHub Repositories
provider:
yahoo-oidc:
issuer-uri: https://api.login.yahoo.com/
issuer-uri: https://api.login.yahoo.com

@ -22,4 +22,4 @@ spring:
client-secret: ${YAHOO-CLIENT-SECRET}
provider:
yahoo-oidc:
issuer-uri: https://api.login.yahoo.com/
issuer-uri: https://api.login.yahoo.com
Loading…
Cancel
Save