From beb123335800f7a9f5eb5160568b5b1d7d108118 Mon Sep 17 00:00:00 2001 From: Joe Grandja Date: Wed, 21 Jul 2021 06:25:19 -0400 Subject: [PATCH] Rename OAuth2TokenIntrospectionClaimAccessor.getScope() to getScopes() Closes gh-354 --- .../oauth2/core/OAuth2TokenIntrospectionClaimAccessor.java | 2 +- .../OAuth2TokenIntrospectionHttpMessageConverter.java | 4 ++-- .../server/authorization/OAuth2TokenIntrospectionTests.java | 4 ++-- .../OAuth2TokenIntrospectionHttpMessageConverterTests.java | 2 +- .../OAuth2TokenIntrospectionAuthenticationProviderTests.java | 2 +- .../web/OAuth2TokenIntrospectionEndpointFilterTests.java | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/core/OAuth2TokenIntrospectionClaimAccessor.java b/oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/core/OAuth2TokenIntrospectionClaimAccessor.java index e26931f3..fd456682 100644 --- a/oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/core/OAuth2TokenIntrospectionClaimAccessor.java +++ b/oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/core/OAuth2TokenIntrospectionClaimAccessor.java @@ -56,7 +56,7 @@ public interface OAuth2TokenIntrospectionClaimAccessor extends ClaimAccessor { * Returns the scopes {@code (scope)} associated with the token * @return the scopes associated with the token */ - default List getScope() { + default List getScopes() { return getClaimAsStringList(OAuth2TokenIntrospectionClaimNames.SCOPE); } diff --git a/oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/core/http/converter/OAuth2TokenIntrospectionHttpMessageConverter.java b/oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/core/http/converter/OAuth2TokenIntrospectionHttpMessageConverter.java index a27ed7e0..89e2ac76 100644 --- a/oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/core/http/converter/OAuth2TokenIntrospectionHttpMessageConverter.java +++ b/oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/core/http/converter/OAuth2TokenIntrospectionHttpMessageConverter.java @@ -184,8 +184,8 @@ public class OAuth2TokenIntrospectionHttpMessageConverter extends AbstractHttpMe @Override public Map convert(OAuth2TokenIntrospection source) { Map responseClaims = new LinkedHashMap<>(source.getClaims()); - if (!CollectionUtils.isEmpty(source.getScope())) { - responseClaims.put(OAuth2TokenIntrospectionClaimNames.SCOPE, StringUtils.collectionToDelimitedString(source.getScope(), " ")); + if (!CollectionUtils.isEmpty(source.getScopes())) { + responseClaims.put(OAuth2TokenIntrospectionClaimNames.SCOPE, StringUtils.collectionToDelimitedString(source.getScopes(), " ")); } if (source.getExpiresAt() != null) { responseClaims.put(OAuth2TokenIntrospectionClaimNames.EXP, source.getExpiresAt().getEpochSecond()); diff --git a/oauth2-authorization-server/src/test/java/org/springframework/security/config/annotation/web/configurers/oauth2/server/authorization/OAuth2TokenIntrospectionTests.java b/oauth2-authorization-server/src/test/java/org/springframework/security/config/annotation/web/configurers/oauth2/server/authorization/OAuth2TokenIntrospectionTests.java index 2c0a61de..330c43b7 100644 --- a/oauth2-authorization-server/src/test/java/org/springframework/security/config/annotation/web/configurers/oauth2/server/authorization/OAuth2TokenIntrospectionTests.java +++ b/oauth2-authorization-server/src/test/java/org/springframework/security/config/annotation/web/configurers/oauth2/server/authorization/OAuth2TokenIntrospectionTests.java @@ -167,7 +167,7 @@ public class OAuth2TokenIntrospectionTests { accessToken.getIssuedAt().minusSeconds(1), accessToken.getIssuedAt().plusSeconds(1)); assertThat(tokenIntrospectionResponse.getExpiresAt()).isBetween( accessToken.getExpiresAt().minusSeconds(1), accessToken.getExpiresAt().plusSeconds(1)); - assertThat(tokenIntrospectionResponse.getScope()).containsExactlyInAnyOrderElementsOf(accessToken.getScopes()); + assertThat(tokenIntrospectionResponse.getScopes()).containsExactlyInAnyOrderElementsOf(accessToken.getScopes()); assertThat(tokenIntrospectionResponse.getTokenType()).isEqualTo(accessToken.getTokenType().getValue()); assertThat(tokenIntrospectionResponse.getNotBefore()).isBetween( tokenClaims.getNotBefore().minusSeconds(1), tokenClaims.getNotBefore().plusSeconds(1)); @@ -207,7 +207,7 @@ public class OAuth2TokenIntrospectionTests { refreshToken.getIssuedAt().minusSeconds(1), refreshToken.getIssuedAt().plusSeconds(1)); assertThat(tokenIntrospectionResponse.getExpiresAt()).isBetween( refreshToken.getExpiresAt().minusSeconds(1), refreshToken.getExpiresAt().plusSeconds(1)); - assertThat(tokenIntrospectionResponse.getScope()).isNull(); + assertThat(tokenIntrospectionResponse.getScopes()).isNull(); assertThat(tokenIntrospectionResponse.getTokenType()).isNull(); assertThat(tokenIntrospectionResponse.getNotBefore()).isNull(); assertThat(tokenIntrospectionResponse.getSubject()).isNull(); diff --git a/oauth2-authorization-server/src/test/java/org/springframework/security/oauth2/core/http/converter/OAuth2TokenIntrospectionHttpMessageConverterTests.java b/oauth2-authorization-server/src/test/java/org/springframework/security/oauth2/core/http/converter/OAuth2TokenIntrospectionHttpMessageConverterTests.java index 3e0af387..40a4408e 100644 --- a/oauth2-authorization-server/src/test/java/org/springframework/security/oauth2/core/http/converter/OAuth2TokenIntrospectionHttpMessageConverterTests.java +++ b/oauth2-authorization-server/src/test/java/org/springframework/security/oauth2/core/http/converter/OAuth2TokenIntrospectionHttpMessageConverterTests.java @@ -90,7 +90,7 @@ public class OAuth2TokenIntrospectionHttpMessageConverterTests { assertThat(tokenIntrospectionResponse.getUsername()).isEqualTo("username1"); assertThat(tokenIntrospectionResponse.getIssuedAt()).isEqualTo(Instant.ofEpochSecond(1607633867L)); assertThat(tokenIntrospectionResponse.getExpiresAt()).isEqualTo(Instant.ofEpochSecond(1607637467L)); - assertThat(tokenIntrospectionResponse.getScope()).containsExactlyInAnyOrderElementsOf(Arrays.asList("scope1", "scope2")); + assertThat(tokenIntrospectionResponse.getScopes()).containsExactlyInAnyOrderElementsOf(Arrays.asList("scope1", "scope2")); assertThat(tokenIntrospectionResponse.getTokenType()).isEqualTo("Bearer"); assertThat(tokenIntrospectionResponse.getNotBefore()).isEqualTo(Instant.ofEpochSecond(1607633867L)); assertThat(tokenIntrospectionResponse.getSubject()).isEqualTo("subject1"); diff --git a/oauth2-authorization-server/src/test/java/org/springframework/security/oauth2/server/authorization/authentication/OAuth2TokenIntrospectionAuthenticationProviderTests.java b/oauth2-authorization-server/src/test/java/org/springframework/security/oauth2/server/authorization/authentication/OAuth2TokenIntrospectionAuthenticationProviderTests.java index 22553366..5a7c2bae 100644 --- a/oauth2-authorization-server/src/test/java/org/springframework/security/oauth2/server/authorization/authentication/OAuth2TokenIntrospectionAuthenticationProviderTests.java +++ b/oauth2-authorization-server/src/test/java/org/springframework/security/oauth2/server/authorization/authentication/OAuth2TokenIntrospectionAuthenticationProviderTests.java @@ -236,7 +236,7 @@ public class OAuth2TokenIntrospectionAuthenticationProviderTests { assertThat(tokenClaims.getClientId()).isEqualTo(authorizedClient.getClientId()); assertThat(tokenClaims.getIssuedAt()).isEqualTo(accessToken.getIssuedAt()); assertThat(tokenClaims.getExpiresAt()).isEqualTo(accessToken.getExpiresAt()); - assertThat(tokenClaims.getScope()).containsExactlyInAnyOrderElementsOf(accessToken.getScopes()); + assertThat(tokenClaims.getScopes()).containsExactlyInAnyOrderElementsOf(accessToken.getScopes()); assertThat(tokenClaims.getTokenType()).isEqualTo(accessToken.getTokenType().getValue()); assertThat(tokenClaims.getNotBefore()).isEqualTo(jwtClaims.getNotBefore()); assertThat(tokenClaims.getSubject()).isEqualTo(jwtClaims.getSubject()); diff --git a/oauth2-authorization-server/src/test/java/org/springframework/security/oauth2/server/authorization/web/OAuth2TokenIntrospectionEndpointFilterTests.java b/oauth2-authorization-server/src/test/java/org/springframework/security/oauth2/server/authorization/web/OAuth2TokenIntrospectionEndpointFilterTests.java index a21d62d9..82a841a8 100644 --- a/oauth2-authorization-server/src/test/java/org/springframework/security/oauth2/server/authorization/web/OAuth2TokenIntrospectionEndpointFilterTests.java +++ b/oauth2-authorization-server/src/test/java/org/springframework/security/oauth2/server/authorization/web/OAuth2TokenIntrospectionEndpointFilterTests.java @@ -218,7 +218,7 @@ public class OAuth2TokenIntrospectionEndpointFilterTests { tokenClaims.getIssuedAt().minusSeconds(1), tokenClaims.getIssuedAt().plusSeconds(1)); assertThat(tokenIntrospectionResponse.getExpiresAt()).isBetween( tokenClaims.getExpiresAt().minusSeconds(1), tokenClaims.getExpiresAt().plusSeconds(1)); - assertThat(tokenIntrospectionResponse.getScope()).containsExactlyInAnyOrderElementsOf(tokenClaims.getScope()); + assertThat(tokenIntrospectionResponse.getScopes()).containsExactlyInAnyOrderElementsOf(tokenClaims.getScopes()); assertThat(tokenIntrospectionResponse.getTokenType()).isEqualTo(tokenClaims.getTokenType()); assertThat(tokenIntrospectionResponse.getNotBefore()).isBetween( tokenClaims.getNotBefore().minusSeconds(1), tokenClaims.getNotBefore().plusSeconds(1));