Skip to content

Commit 32cc7de

Browse files
committed
1 parent 748538d commit 32cc7de

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/web/server/OAuth2AuthorizationCodeGrantWebFilter.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
import org.springframework.security.core.authority.AuthorityUtils;
2424
import org.springframework.security.core.context.ReactiveSecurityContextHolder;
2525
import org.springframework.security.core.context.SecurityContext;
26+
import org.springframework.security.oauth2.core.OAuth2AuthenticationException;
27+
import org.springframework.security.oauth2.core.OAuth2AuthorizationException;
2628
import org.springframework.security.oauth2.client.OAuth2AuthorizedClient;
2729
import org.springframework.security.oauth2.client.authentication.OAuth2AuthorizationCodeAuthenticationToken;
2830
import org.springframework.security.oauth2.client.registration.ReactiveClientRegistrationRepository;
@@ -184,6 +186,8 @@ private Mono<Void> authenticate(ServerWebExchange exchange,
184186
return this.authenticationManager.authenticate(token)
185187
.switchIfEmpty(Mono.defer(() -> Mono.error(new IllegalStateException("No provider found for " + token.getClass()))))
186188
.flatMap(authentication -> onAuthenticationSuccess(authentication, webFilterExchange))
189+
.onErrorResume(OAuth2AuthorizationException.class, e -> this.authenticationFailureHandler
190+
.onAuthenticationFailure(webFilterExchange, new OAuth2AuthenticationException(e.getError())))
187191
.onErrorResume(AuthenticationException.class, e -> this.authenticationFailureHandler
188192
.onAuthenticationFailure(webFilterExchange, e));
189193
}

0 commit comments

Comments
 (0)