Skip to content

Commit

Permalink
oauth2Login() AuthenticationProvider's preserve root cause exception …
Browse files Browse the repository at this point in the history
…when rethrown

Closes spring-projectsgh-10228
  • Loading branch information
jgrandja committed Sep 24, 2021
1 parent 5830fda commit 97c949d
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public Authentication authenticate(Authentication authentication) throws Authent
}
catch (OAuth2AuthorizationException ex) {
OAuth2Error oauth2Error = ex.getError();
throw new OAuth2AuthenticationException(oauth2Error, oauth2Error.toString());
throw new OAuth2AuthenticationException(oauth2Error, oauth2Error.toString(), ex);
}
OAuth2AccessToken accessToken = authorizationCodeAuthenticationToken.getAccessToken();
Map<String, Object> additionalParameters = authorizationCodeAuthenticationToken.getAdditionalParameters();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public Mono<Authentication> authenticate(Authentication authentication) {
}
return this.authorizationCodeManager.authenticate(token)
.onErrorMap(OAuth2AuthorizationException.class,
(e) -> new OAuth2AuthenticationException(e.getError(), e.getError().toString()))
(e) -> new OAuth2AuthenticationException(e.getError(), e.getError().toString(), e))
.cast(OAuth2AuthorizationCodeAuthenticationToken.class).flatMap(this::onSuccess);
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ private OAuth2AccessTokenResponse getResponse(OAuth2LoginAuthenticationToken aut
}
catch (OAuth2AuthorizationException ex) {
OAuth2Error oauth2Error = ex.getError();
throw new OAuth2AuthenticationException(oauth2Error, oauth2Error.toString());
throw new OAuth2AuthenticationException(oauth2Error, oauth2Error.toString(), ex);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public Mono<Authentication> authenticate(Authentication authentication) {
return this.accessTokenResponseClient.getTokenResponse(authzRequest).flatMap(
(accessTokenResponse) -> authenticationResult(authorizationCodeAuthentication, accessTokenResponse))
.onErrorMap(OAuth2AuthorizationException.class,
(e) -> new OAuth2AuthenticationException(e.getError(), e.getError().toString()))
(e) -> new OAuth2AuthenticationException(e.getError(), e.getError().toString(), e))
.onErrorMap(JwtException.class, (e) -> {
OAuth2Error invalidIdTokenError = new OAuth2Error(INVALID_ID_TOKEN_ERROR_CODE, e.getMessage(),
null);
Expand Down

0 comments on commit 97c949d

Please sign in to comment.