|
|
|
@ -1,5 +1,5 @@ |
|
|
|
/* |
|
|
|
/* |
|
|
|
* Copyright 2002-2018 the original author or authors. |
|
|
|
* Copyright 2002-2021 the original author or authors. |
|
|
|
* |
|
|
|
* |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
@ -13,7 +13,6 @@ |
|
|
|
* See the License for the specific language governing permissions and |
|
|
|
* See the License for the specific language governing permissions and |
|
|
|
* limitations under the License. |
|
|
|
* limitations under the License. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
|
|
package org.springframework.security.oauth2.client.userinfo; |
|
|
|
package org.springframework.security.oauth2.client.userinfo; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -22,6 +21,11 @@ import java.util.HashSet; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Set; |
|
|
|
import java.util.Set; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.nimbusds.oauth2.sdk.ErrorObject; |
|
|
|
|
|
|
|
import com.nimbusds.openid.connect.sdk.UserInfoErrorResponse; |
|
|
|
|
|
|
|
import net.minidev.json.JSONObject; |
|
|
|
|
|
|
|
import reactor.core.publisher.Mono; |
|
|
|
|
|
|
|
|
|
|
|
import org.springframework.core.ParameterizedTypeReference; |
|
|
|
import org.springframework.core.ParameterizedTypeReference; |
|
|
|
import org.springframework.http.HttpHeaders; |
|
|
|
import org.springframework.http.HttpHeaders; |
|
|
|
import org.springframework.http.HttpStatus; |
|
|
|
import org.springframework.http.HttpStatus; |
|
|
|
@ -41,12 +45,6 @@ import org.springframework.util.StringUtils; |
|
|
|
import org.springframework.web.reactive.function.client.ClientResponse; |
|
|
|
import org.springframework.web.reactive.function.client.ClientResponse; |
|
|
|
import org.springframework.web.reactive.function.client.WebClient; |
|
|
|
import org.springframework.web.reactive.function.client.WebClient; |
|
|
|
|
|
|
|
|
|
|
|
import com.nimbusds.oauth2.sdk.ErrorObject; |
|
|
|
|
|
|
|
import com.nimbusds.openid.connect.sdk.UserInfoErrorResponse; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import net.minidev.json.JSONObject; |
|
|
|
|
|
|
|
import reactor.core.publisher.Mono; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* An implementation of an {@link ReactiveOAuth2UserService} that supports standard OAuth 2.0 Provider's. |
|
|
|
* An implementation of an {@link ReactiveOAuth2UserService} that supports standard OAuth 2.0 Provider's. |
|
|
|
* <p> |
|
|
|
* <p> |
|
|
|
@ -119,7 +117,7 @@ public class DefaultReactiveOAuth2UserService implements ReactiveOAuth2UserServi |
|
|
|
} |
|
|
|
} |
|
|
|
Mono<Map<String, Object>> userAttributes = requestHeadersSpec |
|
|
|
Mono<Map<String, Object>> userAttributes = requestHeadersSpec |
|
|
|
.retrieve() |
|
|
|
.retrieve() |
|
|
|
.onStatus(s -> s != HttpStatus.OK, response -> parse(response).map(userInfoErrorResponse -> { |
|
|
|
.onStatus(HttpStatus::isError, response -> parse(response).map(userInfoErrorResponse -> { |
|
|
|
String description = userInfoErrorResponse.getErrorObject().getDescription(); |
|
|
|
String description = userInfoErrorResponse.getErrorObject().getDescription(); |
|
|
|
OAuth2Error oauth2Error = new OAuth2Error( |
|
|
|
OAuth2Error oauth2Error = new OAuth2Error( |
|
|
|
INVALID_USER_INFO_RESPONSE_ERROR_CODE, description, |
|
|
|
INVALID_USER_INFO_RESPONSE_ERROR_CODE, description, |
|
|
|
|