Skip to content

Commit 4fbe06d

Browse files
committed
Fix inconsistent state when authorization consent is denied
Closes gh-595
1 parent 58bac49 commit 4fbe06d

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-2021 the original author or authors.
2+
* Copyright 2020-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -577,8 +577,6 @@ private static OAuth2AuthorizationCodeRequestAuthenticationToken.Builder from(OA
577577
.scopes(authorizationCodeRequestAuthentication.getScopes())
578578
.state(authorizationCodeRequestAuthentication.getState())
579579
.additionalParameters(authorizationCodeRequestAuthentication.getAdditionalParameters())
580-
.consentRequired(authorizationCodeRequestAuthentication.isConsentRequired())
581-
.consent(authorizationCodeRequestAuthentication.isConsent())
582580
.authorizationCode(authorizationCodeRequestAuthentication.getAuthorizationCode());
583581
}
584582

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

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2020-2021 the original author or authors.
2+
* Copyright 2020-2022 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -1013,6 +1013,12 @@ private static void assertAuthenticationException(OAuth2AuthorizationCodeRequest
10131013
OAuth2AuthorizationCodeRequestAuthenticationToken authorizationCodeRequestAuthentication =
10141014
authenticationException.getAuthorizationCodeRequestAuthentication();
10151015
assertThat(authorizationCodeRequestAuthentication.getRedirectUri()).isEqualTo(redirectUri);
1016+
1017+
// gh-595
1018+
if (OAuth2ErrorCodes.ACCESS_DENIED.equals(errorCode)) {
1019+
assertThat(authorizationCodeRequestAuthentication.isConsent()).isFalse();
1020+
assertThat(authorizationCodeRequestAuthentication.isConsentRequired()).isFalse();
1021+
}
10161022
}
10171023

10181024
private static OAuth2AuthorizationCodeRequestAuthenticationToken.Builder authorizationCodeRequestAuthentication(

0 commit comments

Comments
 (0)