クラス DefaultReactiveOAuth2UserService

java.lang.ObjectSE
org.springframework.security.oauth2.client.userinfo.DefaultReactiveOAuth2UserService
実装されたすべてのインターフェース:
ReactiveOAuth2UserService<OAuth2UserRequest,OAuth2User>

public class DefaultReactiveOAuth2UserService extends ObjectSE implements ReactiveOAuth2UserService<OAuth2UserRequest,OAuth2User>
標準の OAuth 2.0 プロバイダーをサポートする ReactiveOAuth2UserService の実装。

標準の OAuth 2.0 プロバイダーの場合、UserInfo レスポンスからユーザーの名前にアクセスするために使用される属性名が必要であるため、UserInfoEndpoint.getUserNameAttributeName() を介して使用可能でなければなりません。

: 属性名はプロバイダー間で標準化されていないため、異なる場合があります。サポートされるユーザー属性名のセットについては、プロバイダーの API ドキュメントを参照してください。

導入:
5.1
関連事項:
  • コンストラクターの詳細

    • DefaultReactiveOAuth2UserService

      public DefaultReactiveOAuth2UserService()
  • メソッドの詳細

    • loadUser

      public reactor.core.publisher.Mono<OAuth2User> loadUser(OAuth2UserRequest userRequest) throws OAuth2AuthenticationException
      インターフェースからコピーされた説明: ReactiveOAuth2UserService
      UserInfo エンドポイントからエンドユーザーのユーザー属性を取得した後、OAuth2User を返します。
      次で指定:
      インターフェース ReactiveOAuth2UserService<OAuth2UserRequest,OAuth2User>loadUser 
      パラメーター:
      userRequest - ユーザーリクエスト
      戻り値:
      OAuth2User
      例外:
      OAuth2AuthenticationException - UserInfo エンドポイントからユーザー属性を取得しようとしてエラーが発生した場合
    • setAttributesConverter

      public void setAttributesConverter(org.springframework.core.convert.converter.Converter<OAuth2UserRequest,org.springframework.core.convert.converter.Converter<MapSE<StringSE,ObjectSE>,MapSE<StringSE,ObjectSE>>> attributesConverter)
      この戦略を使用して、ユーザー属性を Spring Security が理解できる形式に適合させます。デフォルトでは、元の属性が保持されます。

      これは、たとえば、ユーザー属性がネストされている場合に役立ちます。Spring Security ではユーザー名属性を最上位レベルに配置する必要があるため、このメソッドを使用して次の操作を実行できます。

           DefaultReactiveOAuth2UserService userService = new DefaultReactiveOAuth2UserService();
           userService.setAttributesConverter((userRequest) -> (attributes) ->
               Map<String, Object> userObject = (Map<String, Object>) attributes.get("user");
               attributes.put("user-name", userObject.get("user-name"));
               return attributes;
           });
       
      パラメーター:
      attributesConverter - 使用する属性適応戦略
      導入:
      6.3
    • setWebClient

      public void setWebClient(org.springframework.web.reactive.function.client.WebClient webClient)
      ユーザーエンドポイントの取得に使用する WebClient を設定します
      パラメーター:
      webClient - 使用するクライアント