DefaultReactiveOAuth2UserService IOException
Improve handling of IOException to report an AuthenticationServiceExceptionThere are many reasons that a DefaultReactiveOAuth2UserService might fail due to an IOException (i.e. SSLHandshakeException). In those cases we should use a AuthenticationServiceException so that users are aware there is likely some misconfiguration. Fixes gh-7370
This commit is contained in:
parent
7ad641d106
commit
2a3bf9b6bb
|
@ -17,7 +17,7 @@
|
|||
package org.springframework.security.oauth2.client.userinfo;
|
||||
|
||||
|
||||
import java.net.UnknownHostException;
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
@ -140,7 +140,7 @@ public class DefaultReactiveOAuth2UserService implements ReactiveOAuth2UserServi
|
|||
|
||||
return new DefaultOAuth2User(authorities, attrs, userNameAttributeName);
|
||||
})
|
||||
.onErrorMap(UnknownHostException.class, t -> new AuthenticationServiceException("Unable to access the userInfoEndpoint " + userInfoUri, t))
|
||||
.onErrorMap(e -> e instanceof IOException, t -> new AuthenticationServiceException("Unable to access the userInfoEndpoint " + userInfoUri, t))
|
||||
.onErrorMap(t -> !(t instanceof AuthenticationServiceException), t -> {
|
||||
OAuth2Error oauth2Error = new OAuth2Error(INVALID_USER_INFO_RESPONSE_ERROR_CODE, "An error occurred reading the UserInfo Success response: " + t.getMessage(), null);
|
||||
return new OAuth2AuthenticationException(oauth2Error, oauth2Error.toString(), t);
|
||||
|
|
Loading…
Reference in New Issue