Skip to content

Commit 2a3bf9b

Browse files
committed
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
1 parent 7ad641d commit 2a3bf9b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

oauth2/oauth2-client/src/main/java/org/springframework/security/oauth2/client/userinfo/DefaultReactiveOAuth2UserService.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
package org.springframework.security.oauth2.client.userinfo;
1818

1919

20-
import java.net.UnknownHostException;
20+
import java.io.IOException;
2121
import java.util.HashSet;
2222
import java.util.Map;
2323
import java.util.Set;
@@ -140,7 +140,7 @@ public Mono<OAuth2User> loadUser(OAuth2UserRequest userRequest)
140140

141141
return new DefaultOAuth2User(authorities, attrs, userNameAttributeName);
142142
})
143-
.onErrorMap(UnknownHostException.class, t -> new AuthenticationServiceException("Unable to access the userInfoEndpoint " + userInfoUri, t))
143+
.onErrorMap(e -> e instanceof IOException, t -> new AuthenticationServiceException("Unable to access the userInfoEndpoint " + userInfoUri, t))
144144
.onErrorMap(t -> !(t instanceof AuthenticationServiceException), t -> {
145145
OAuth2Error oauth2Error = new OAuth2Error(INVALID_USER_INFO_RESPONSE_ERROR_CODE, "An error occurred reading the UserInfo Success response: " + t.getMessage(), null);
146146
return new OAuth2AuthenticationException(oauth2Error, oauth2Error.toString(), t);

0 commit comments

Comments
 (0)