Skip to content

Commit 99b5960

Browse files
Remove the openid scope matcher in OAuth2AuthorizationCodeRequestAuthenticationConverter
1 parent d79f13e commit 99b5960

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

Diff for: oauth2-authorization-server/src/main/java/org/springframework/security/oauth2/server/authorization/web/authentication/OAuth2AuthorizationCodeRequestAuthenticationConverter.java

+4-8
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,11 @@ public final class OAuth2AuthorizationCodeRequestAuthenticationConverter impleme
6464
private static final Authentication ANONYMOUS_AUTHENTICATION = new AnonymousAuthenticationToken("anonymous",
6565
"anonymousUser", AuthorityUtils.createAuthorityList("ROLE_ANONYMOUS"));
6666

67-
private static final RequestMatcher OIDC_REQUEST_MATCHER = createOidcRequestMatcher();
67+
private static final RequestMatcher POST_WITH_RESPONSE_TYPE_REQUEST_MATCHER = createPostWithResponseTypeRequestMatcher();
6868

6969
@Override
7070
public Authentication convert(HttpServletRequest request) {
71-
if (!"GET".equals(request.getMethod()) && !OIDC_REQUEST_MATCHER.matches(request)) {
71+
if (!"GET".equals(request.getMethod()) && !POST_WITH_RESPONSE_TYPE_REQUEST_MATCHER.matches(request)) {
7272
return null;
7373
}
7474

@@ -153,15 +153,11 @@ else if (!responseType.equals(OAuth2AuthorizationResponseType.CODE.getValue()))
153153
state, scopes, additionalParameters);
154154
}
155155

156-
private static RequestMatcher createOidcRequestMatcher() {
156+
private static RequestMatcher createPostWithResponseTypeRequestMatcher() {
157157
RequestMatcher postMethodMatcher = (request) -> "POST".equals(request.getMethod());
158158
RequestMatcher responseTypeParameterMatcher = (
159159
request) -> request.getParameter(OAuth2ParameterNames.RESPONSE_TYPE) != null;
160-
RequestMatcher openidScopeMatcher = (request) -> {
161-
String scope = request.getParameter(OAuth2ParameterNames.SCOPE);
162-
return StringUtils.hasText(scope) && scope.contains(OidcScopes.OPENID);
163-
};
164-
return new AndRequestMatcher(postMethodMatcher, responseTypeParameterMatcher, openidScopeMatcher);
160+
return new AndRequestMatcher(postMethodMatcher, responseTypeParameterMatcher);
165161
}
166162

167163
private static void throwError(String errorCode, String parameterName) {

0 commit comments

Comments
 (0)