Skip to content

Commit 8c71e56

Browse files
committed
Polish gh-168
1 parent 7c7e664 commit 8c71e56

File tree

3 files changed

+6
-7
lines changed

3 files changed

+6
-7
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,7 @@ public Authentication authenticate(Authentication authentication) throws Authent
127127
.accessToken(accessToken);
128128

129129
OAuth2RefreshToken refreshToken = null;
130-
if (registeredClient.getAuthorizationGrantTypes()
131-
.contains(AuthorizationGrantType.REFRESH_TOKEN)) {
130+
if (registeredClient.getAuthorizationGrantTypes().contains(AuthorizationGrantType.REFRESH_TOKEN)) {
132131
refreshToken = OAuth2TokenIssuerUtil.issueRefreshToken(registeredClient.getTokenSettings().refreshTokenTimeToLive());
133132
tokensBuilder.refreshToken(refreshToken);
134133
}

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import org.junit.Test;
2020
import org.mockito.ArgumentCaptor;
2121
import org.springframework.security.authentication.TestingAuthenticationToken;
22+
import org.springframework.security.oauth2.core.AuthorizationGrantType;
2223
import org.springframework.security.oauth2.core.ClientAuthenticationMethod;
2324
import org.springframework.security.oauth2.core.OAuth2AuthenticationException;
2425
import org.springframework.security.oauth2.core.OAuth2ErrorCodes;
@@ -292,9 +293,9 @@ public void authenticateWhenTokenTimeToLiveConfiguredThenTokenExpirySet() {
292293
}
293294

294295
@Test
295-
public void authenticateWhenRefreshTokenDisabledThenRefreshTokenNull() {
296+
public void authenticateWhenRefreshTokenGrantNotConfiguredThenRefreshTokenNotIssued() {
296297
RegisteredClient registeredClient = TestRegisteredClients.registeredClient()
297-
.tokenSettings(tokenSettings -> tokenSettings.enableRefreshTokens(false))
298+
.authorizationGrantTypes(grantTypes -> grantTypes.remove(AuthorizationGrantType.REFRESH_TOKEN))
298299
.build();
299300

300301
OAuth2Authorization authorization = TestOAuth2Authorizations.authorization(registeredClient).build();

samples/boot/oauth2-integration/authorizationserver/src/main/java/sample/config/AuthorizationServerConfig.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,13 @@ public class AuthorizationServerConfig {
4141
@Bean
4242
public RegisteredClientRepository registeredClientRepository() {
4343
RegisteredClient registeredClient = RegisteredClient.withId(UUID.randomUUID().toString())
44-
.clientId("client")
44+
.clientId("messaging-client")
4545
.clientSecret("secret")
4646
.clientAuthenticationMethod(ClientAuthenticationMethod.BASIC)
4747
.authorizationGrantType(AuthorizationGrantType.AUTHORIZATION_CODE)
48-
// .authorizationGrantType(AuthorizationGrantType.REFRESH_TOKEN)
4948
.authorizationGrantType(AuthorizationGrantType.CLIENT_CREDENTIALS)
5049
.redirectUri("http://localhost:8080/authorized")
51-
.scope("read")
50+
.scope("message.read")
5251
.scope("message.write")
5352
.clientSettings(clientSettings -> clientSettings.requireUserConsent(true))
5453
.build();

0 commit comments

Comments
 (0)