Skip to content

Commit 7d06aaa

Browse files
committed
Resolve reviews
Signed-off-by: fine-pine <[email protected]>
1 parent 4ea9a73 commit 7d06aaa

File tree

4 files changed

+8
-40
lines changed

4 files changed

+8
-40
lines changed

oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/authentication/OAuth2DeviceAuthorizationRequestAuthenticationProvider.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,9 @@ public Authentication authenticate(Authentication authentication) throws Authent
121121
throwError(OAuth2ErrorCodes.INVALID_SCOPE, OAuth2ParameterNames.SCOPE);
122122
}
123123
}
124-
}
125-
126-
if (requestedScopes.contains(OidcScopes.OPENID)) {
127-
throwError(OAuth2ErrorCodes.INVALID_SCOPE, OAuth2ParameterNames.SCOPE);
124+
if (requestedScopes.contains(OidcScopes.OPENID)) {
125+
throwError(OAuth2ErrorCodes.INVALID_SCOPE, OAuth2ParameterNames.SCOPE);
126+
}
128127
}
129128

130129
if (this.logger.isTraceEnabled()) {

oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/authentication/OAuth2RefreshTokenAuthenticationProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ public Authentication authenticate(Authentication authentication) throws Authent
215215

216216
// ----- ID token -----
217217
OidcIdToken idToken;
218-
if (authorizedScopes.contains(OidcScopes.OPENID) && authorization.getToken(OidcIdToken.class) != null) {
218+
if (authorizedScopes.contains(OidcScopes.OPENID)) {
219219
// @formatter:off
220220
tokenContext = tokenContextBuilder
221221
.tokenType(ID_TOKEN_TOKEN_TYPE)

oauth2-authorization-server/src/test/java/org/springframework/security/oauth2/server/authorization/authentication/OAuth2DeviceAuthorizationRequestAuthenticationProviderTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,9 +169,9 @@ public void authenticateWhenInvalidScopesThenThrowOAuth2AuthenticationException(
169169
@Test
170170
public void authenticateWhenOpenIdScopeThenThrowOAuth2AuthenticationException() {
171171
RegisteredClient registeredClient = TestRegisteredClients.registeredClient()
172-
.authorizationGrantType(AuthorizationGrantType.DEVICE_CODE)
173-
.scope(OidcScopes.OPENID)
174-
.build();
172+
.authorizationGrantType(AuthorizationGrantType.DEVICE_CODE)
173+
.scope(OidcScopes.OPENID)
174+
.build();
175175
Authentication authentication = createAuthentication(registeredClient);
176176
// @formatter:off
177177
assertThatExceptionOfType(OAuth2AuthenticationException.class)

oauth2-authorization-server/src/test/java/org/springframework/security/oauth2/server/authorization/authentication/OAuth2RefreshTokenAuthenticationProviderTests.java

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -571,17 +571,7 @@ public void authenticateWhenRefreshTokenNotGeneratedThenThrowOAuth2Authenticatio
571571
@Test
572572
public void authenticateWhenIdTokenNotGeneratedThenThrowOAuth2AuthenticationException() {
573573
RegisteredClient registeredClient = TestRegisteredClients.registeredClient().scope(OidcScopes.OPENID).build();
574-
OidcIdToken authorizedIdToken = OidcIdToken.withTokenValue("id-token")
575-
.issuer("https://provider.com")
576-
.subject("subject")
577-
.issuedAt(Instant.now())
578-
.expiresAt(Instant.now().plusSeconds(60))
579-
.claim("sid", "sessionId-1234")
580-
.claim(IdTokenClaimNames.AUTH_TIME, Date.from(Instant.now()))
581-
.build();
582-
OAuth2Authorization authorization = TestOAuth2Authorizations.authorization(registeredClient)
583-
.token(authorizedIdToken)
584-
.build();
574+
OAuth2Authorization authorization = TestOAuth2Authorizations.authorization(registeredClient).build();
585575
given(this.authorizationService.findByToken(eq(authorization.getRefreshToken().getToken().getTokenValue()),
586576
eq(OAuth2TokenType.REFRESH_TOKEN)))
587577
.willReturn(authorization);
@@ -610,27 +600,6 @@ public void authenticateWhenIdTokenNotGeneratedThenThrowOAuth2AuthenticationExce
610600
});
611601
}
612602

613-
@Test
614-
public void authenticateAuthorizationWithoutIdTokenThenIdTokenNotGenerated() {
615-
RegisteredClient registeredClient = TestRegisteredClients.registeredClient().scope(OidcScopes.OPENID).build();
616-
OAuth2Authorization authorization = TestOAuth2Authorizations.authorization(registeredClient).build();
617-
given(this.authorizationService.findByToken(eq(authorization.getRefreshToken().getToken().getTokenValue()),
618-
eq(OAuth2TokenType.REFRESH_TOKEN)))
619-
.willReturn(authorization);
620-
621-
OAuth2ClientAuthenticationToken clientPrincipal = new OAuth2ClientAuthenticationToken(registeredClient,
622-
ClientAuthenticationMethod.CLIENT_SECRET_BASIC, registeredClient.getClientSecret());
623-
OAuth2RefreshTokenAuthenticationToken authentication = new OAuth2RefreshTokenAuthenticationToken(
624-
authorization.getRefreshToken().getToken().getTokenValue(), clientPrincipal, null, null);
625-
626-
627-
OAuth2AccessTokenAuthenticationToken accessTokenAuthentication = (OAuth2AccessTokenAuthenticationToken) this.authenticationProvider
628-
.authenticate(authentication);
629-
630-
assertThat(accessTokenAuthentication.getAdditionalParameters().containsKey(OidcParameterNames.ID_TOKEN))
631-
.isFalse();
632-
}
633-
634603
@Test
635604
public void authenticateWhenAccessTokenFormatReferenceThenAccessTokenGeneratorCalled() {
636605
// @formatter:off

0 commit comments

Comments
 (0)