oauth2Login() AuthenticationProvider's preserve root cause exception when rethrown

Closes gh-10228
This commit is contained in:
Joe Grandja 2021-09-24 10:32:41 -04:00
parent 5830fda2fa
commit 97c949d929
4 changed files with 4 additions and 4 deletions

View File

@ -110,7 +110,7 @@ public class OAuth2LoginAuthenticationProvider implements AuthenticationProvider
}
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();

View File

@ -99,7 +99,7 @@ public class OAuth2LoginReactiveAuthenticationManager implements ReactiveAuthent
}
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);
});
}

View File

@ -173,7 +173,7 @@ public class OidcAuthorizationCodeAuthenticationProvider implements Authenticati
}
catch (OAuth2AuthorizationException ex) {
OAuth2Error oauth2Error = ex.getError();
throw new OAuth2AuthenticationException(oauth2Error, oauth2Error.toString());
throw new OAuth2AuthenticationException(oauth2Error, oauth2Error.toString(), ex);
}
}

View File

@ -142,7 +142,7 @@ public class OidcAuthorizationCodeReactiveAuthenticationManager implements React
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);