Skip to content

Commit 3938ea4

Browse files
committed
Don't set any scope as discussed in PR 8790
#8790
1 parent 81b4d82 commit 3938ea4

File tree

3 files changed

+2
-39
lines changed

3 files changed

+2
-39
lines changed

config/src/test/java/org/springframework/security/config/oauth2/client/ClientRegistrationsBeanDefinitionParserTests.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ public void parseWhenIssuerUriConfiguredThenRequestConfigFromIssuer() throws Exc
152152
assertThat(googleRegistration.getClientAuthenticationMethod()).isEqualTo(ClientAuthenticationMethod.BASIC);
153153
assertThat(googleRegistration.getAuthorizationGrantType()).isEqualTo(AuthorizationGrantType.AUTHORIZATION_CODE);
154154
assertThat(googleRegistration.getRedirectUri()).isEqualTo("{baseUrl}/{action}/oauth2/code/{registrationId}");
155-
assertThat(googleRegistration.getScopes()).isEqualTo(StringUtils.commaDelimitedListToSet("openid"));
155+
assertThat(googleRegistration.getScopes()).isNull();
156156
assertThat(googleRegistration.getClientName()).isEqualTo(serverUrl);
157157

158158
ProviderDetails googleProviderDetails = googleRegistration.getProviderDetails();

oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/registration/ClientRegistrations.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
import org.springframework.security.oauth2.core.AuthorizationGrantType;
3535
import org.springframework.security.oauth2.core.ClientAuthenticationMethod;
3636
import org.springframework.security.oauth2.core.oidc.IdTokenClaimNames;
37-
import org.springframework.security.oauth2.core.oidc.OidcScopes;
3837
import org.springframework.util.Assert;
3938
import org.springframework.web.client.HttpClientErrorException;
4039
import org.springframework.web.client.RestTemplate;
@@ -239,7 +238,6 @@ private static ClientRegistration.Builder withProviderConfiguration(Authorizatio
239238

240239
return ClientRegistration.withRegistrationId(name)
241240
.userNameAttributeName(IdTokenClaimNames.SUB)
242-
.scope(OidcScopes.OPENID) // default to "openid" which must be supported
243241
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE)
244242
.clientAuthenticationMethod(method)
245243
.redirectUri("{baseUrl}/{action}/oauth2/code/{registrationId}")

oauth2/oauth2-client/src/test/java/org/springframework/security/oauth2/client/registration/ClientRegistrationsTest.java

Lines changed: 1 addition & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ private void assertIssuerMetadata(ClientRegistration registration,
158158
assertThat(registration.getAuthorizationGrantType()).isEqualTo(AuthorizationGrantType.AUTHORIZATION_CODE);
159159
assertThat(registration.getRegistrationId()).isEqualTo(this.server.getHostName());
160160
assertThat(registration.getClientName()).isEqualTo(this.issuer);
161-
assertThat(registration.getScopes()).containsOnly("openid");
161+
assertThat(registration.getScopes()).isNull();
162162
assertThat(provider.getAuthorizationUri()).isEqualTo("https://example.com/o/oauth2/v2/auth");
163163
assertThat(provider.getTokenUri()).isEqualTo("https://example.com/oauth2/v4/token");
164164
assertThat(provider.getJwkSetUri()).isEqualTo("https://example.com/oauth2/v3/certs");
@@ -222,41 +222,6 @@ public void issuerWhenOAuth2ContainsTrailingSlashThenSuccess() throws Exception
222222
assertThat(this.issuer).endsWith("/");
223223
}
224224

225-
/**
226-
* https://openid.net/specs/openid-connect-discovery-1_0.html#ProviderMetadata
227-
*
228-
* RECOMMENDED. JSON array containing a list of the OAuth 2.0 [RFC6749] scope values that this server supports. The
229-
* server MUST support the openid scope value.
230-
* @throws Exception
231-
*/
232-
@Test
233-
public void issuerWhenScopesNullThenScopesDefaulted() throws Exception {
234-
this.response.remove("scopes_supported");
235-
236-
ClientRegistration registration = registration("").build();
237-
238-
assertThat(registration.getScopes()).containsOnly("openid");
239-
}
240-
241-
@Test
242-
public void issuerWhenOidcFallbackScopesNullThenScopesDefaulted() throws Exception {
243-
this.response.remove("scopes_supported");
244-
245-
ClientRegistration registration = registrationOidcFallback("", null).build();
246-
247-
assertThat(registration.getScopes()).containsOnly("openid");
248-
}
249-
250-
@Test
251-
public void issuerWhenOAuth2ScopesNullThenScopesDefaulted() throws Exception {
252-
this.response.remove("scopes_supported");
253-
254-
ClientRegistration registration = registrationOAuth2("", null).build();
255-
256-
assertThat(registration.getScopes()).containsOnly("openid");
257-
}
258-
259-
260225
@Test
261226
public void issuerWhenGrantTypesSupportedNullThenDefaulted() throws Exception {
262227
this.response.remove("grant_types_supported");

0 commit comments

Comments
 (0)