クラス ServerHttpSecurity


  • public class ServerHttpSecurity
    extends java.lang.Object
    ServerHttpSecurity は Spring Security の HttpSecurity に似ていますが、WebFlux 用です。特定の http リクエストに対して Web ベースのセキュリティを構成できます。デフォルトでは、すべてのリクエストに適用されますが、securityMatcher(ServerWebExchangeMatcher) または他の同様の方法を使用して制限できます。最小構成は次のとおりです。
     @EnableWebFluxSecurity
     public class MyMinimalSecurityConfiguration {
    
         @Bean
         public MapReactiveUserDetailsService userDetailsService() {
             UserDetails user = User.withDefaultPasswordEncoder()
                 .username("user")
                 .password("password")
                 .roles("USER")
                 .build();
             return new MapReactiveUserDetailsService(user);
         }
     }
     
    以下は最小構成と同じですが、明示的に ServerHttpSecurity を宣言しています。
     @EnableWebFluxSecurity
     public class MyExplicitSecurityConfiguration {
    
         @Bean
         public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
             http
                 .authorizeExchange()
                   .anyExchange().authenticated()
                 .and()
                   .httpBasic().and()
                   .formLogin();
                 return http.build();
         }
    
         @Bean
         public MapReactiveUserDetailsService userDetailsService() {
             UserDetails user = User.withDefaultPasswordEncoder()
                 .username("user")
                 .password("password")
                 .roles("USER")
                 .build();
             return new MapReactiveUserDetailsService(user);
         }
     }
     
    導入:
    5.0
    • コンストラクターの詳細

      • ServerHttpSecurity

        protected ServerHttpSecurity()
    • メソッドの詳細

      • securityMatcher

        public ServerHttpSecurity securityMatcher​(ServerWebExchangeMatcher matcher)
        この HttpSecurity インスタンスに適用されるリクエストを決定する ServerExchangeMatcher。
        パラメーター:
        matcher - この HttpSecurity インスタンスに適用されるリクエストを決定する ServerExchangeMatcher。デフォルトはすべてのリクエストです。
        戻り値:
        ServerHttpSecurity の構成を続行するには
      • addFilterAt

        public ServerHttpSecurity addFilterAt​(org.springframework.web.server.WebFilter webFilter,
                                              SecurityWebFiltersOrder order)
        特定の位置に WebFilter を追加します。
        パラメーター:
        webFilter - 追加する WebFilter 
        order - WebFilter を挿入する場所
        戻り値:
        ServerHttpSecurity の構成を続行するには
      • addFilterBefore

        public ServerHttpSecurity addFilterBefore​(org.springframework.web.server.WebFilter webFilter,
                                                  SecurityWebFiltersOrder order)
        特定の位置の前に WebFilter を追加します。
        パラメーター:
        webFilter - 追加する WebFilter 
        order - WebFilter を挿入する前の場所
        戻り値:
        ServerHttpSecurity の構成を続行するには
        導入:
        5.2.0
      • addFilterAfter

        public ServerHttpSecurity addFilterAfter​(org.springframework.web.server.WebFilter webFilter,
                                                 SecurityWebFiltersOrder order)
        特定の位置の後に WebFilter を追加します。
        パラメーター:
        webFilter - 追加する WebFilter 
        order - WebFilter を挿入する場所
        戻り値:
        ServerHttpSecurity の構成を続行するには
        導入:
        5.2.0
      • redirectToHttps

        public ServerHttpSecurity.HttpsRedirectSpec redirectToHttps()
        HTTPS リダイレクトルールを設定します。デフォルトが使用される場合:
          @Bean
                public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
                    http
                        // ...
                        .redirectToHttps();
                    return http.build();
                }
         
        その後、すべての非 HTTPS リクエストが HTTPS にリダイレクトされます。通常、すべてのリクエストは HTTPS である必要があります。ただし、リダイレクトの焦点を絞ることもできます。
          @Bean
                public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
                    http
                        // ...
                        .redirectToHttps()
                            .httpsRedirectWhen((serverWebExchange) ->
                                serverWebExchange.getRequest().getHeaders().containsKey("X-Requires-Https"))
                    return http.build();
                }
         
        戻り値:
        ServerHttpSecurity.HttpsRedirectSpec をカスタマイズする
      • redirectToHttps

        public ServerHttpSecurity redirectToHttps​(Customizer<ServerHttpSecurity.HttpsRedirectSpec> httpsRedirectCustomizer)
        HTTPS リダイレクトルールを設定します。デフォルトが使用される場合:
          @Bean
                public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
                    http
                        // ...
                        .redirectToHttps(withDefaults());
                    return http.build();
                }
         
        その後、すべての非 HTTPS リクエストが HTTPS にリダイレクトされます。通常、すべてのリクエストは HTTPS である必要があります。ただし、リダイレクトの焦点を絞ることもできます。
          @Bean
                public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
                    http
                        // ...
                        .redirectToHttps((redirectToHttps) ->
                                redirectToHttps
                                .httpsRedirectWhen((serverWebExchange) ->
                                        serverWebExchange.getRequest().getHeaders().containsKey("X-Requires-Https"))
                            );
                    return http.build();
                }
         
        パラメーター:
        httpsRedirectCustomizer - Customizer を使用して、ServerHttpSecurity.HttpsRedirectSpec により多くのオプションを提供します。
        戻り値:
        ServerHttpSecurity をカスタマイズする
      • csrf

        public ServerHttpSecurity.CsrfSpec csrf()
        デフォルトで有効になっている CSRF の保護を設定します。次を使用して無効にできます。
          @Bean
          public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
              http
                  // ...
                  .csrf().disabled();
              return http.build();
          }
         
        追加の構成オプションは以下のとおりです。
          @Bean
          public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
              http
                  // ...
                  .csrf()
                      // Handle CSRF failures
                      .accessDeniedHandler(accessDeniedHandler)
                      // Custom persistence of CSRF Token
                      .csrfTokenRepository(csrfTokenRepository)
                      // custom matching when CSRF protection is enabled
                      .requireCsrfProtectionMatcher(matcher);
              return http.build();
          }
         
        戻り値:
        ServerHttpSecurity.CsrfSpec をカスタマイズする
      • csrf

        public ServerHttpSecurity csrf​(Customizer<ServerHttpSecurity.CsrfSpec> csrfCustomizer)
        デフォルトで有効になっている CSRF の保護を設定します。次を使用して無効にできます。
          @Bean
          public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
              http
                  // ...
                  .csrf((csrf) ->
                      csrf.disabled()
                  );
              return http.build();
          }
         
        追加の構成オプションは以下のとおりです。
          @Bean
          public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
              http
                  // ...
                  .csrf((csrf) ->
                      csrf
                          // Handle CSRF failures
                          .accessDeniedHandler(accessDeniedHandler)
                          // Custom persistence of CSRF Token
                          .csrfTokenRepository(csrfTokenRepository)
                          // custom matching when CSRF protection is enabled
                          .requireCsrfProtectionMatcher(matcher)
                  );
              return http.build();
          }
         
        パラメーター:
        csrfCustomizer - Customizer を使用して、ServerHttpSecurity.CsrfSpec により多くのオプションを提供します。
        戻り値:
        ServerHttpSecurity をカスタマイズする
      • anonymous

        public ServerHttpSecurity.AnonymousSpec anonymous()
        匿名認証を有効にして構成します。匿名認証はデフォルトで無効になっています。
          @Bean
          public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
              http
                  // ...
                  .anonymous().key("key")
                  .authorities("ROLE_ANONYMOUS");
              return http.build();
          }
         
        戻り値:
        ServerHttpSecurity.AnonymousSpec をカスタマイズする
        導入:
        5.2.0
      • anonymous

        public ServerHttpSecurity anonymous​(Customizer<ServerHttpSecurity.AnonymousSpec> anonymousCustomizer)
        匿名認証を有効にして構成します。匿名認証はデフォルトで無効になっています。
          @Bean
          public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
              http
                  // ...
                  .anonymous((anonymous) ->
                      anonymous
                          .key("key")
                          .authorities("ROLE_ANONYMOUS")
                  );
              return http.build();
          }
         
        パラメーター:
        anonymousCustomizer - Customizer を使用して、ServerHttpSecurity.AnonymousSpec により多くのオプションを提供します。
        戻り値:
        ServerHttpSecurity をカスタマイズする
      • httpBasic

        public ServerHttpSecurity.HttpBasicSpec httpBasic()
        HTTP 基本認証を構成します。以下に設定例を示します。
          @Bean
          public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
              http
                  // ...
                  .httpBasic()
                      // used for authenticating the credentials
                      .authenticationManager(authenticationManager)
                      // Custom persistence of the authentication
                      .securityContextRepository(securityContextRepository);
              return http.build();
          }
         
        戻り値:
        ServerHttpSecurity.HttpBasicSpec をカスタマイズする
      • httpBasic

        public ServerHttpSecurity httpBasic​(Customizer<ServerHttpSecurity.HttpBasicSpec> httpBasicCustomizer)
        HTTP 基本認証を構成します。以下に設定例を示します。
          @Bean
          public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
              http
                  // ...
                  .httpBasic((httpBasic) ->
                      httpBasic
                          // used for authenticating the credentials
                          .authenticationManager(authenticationManager)
                          // Custom persistence of the authentication
                          .securityContextRepository(securityContextRepository)
                      );
              return http.build();
          }
         
        パラメーター:
        httpBasicCustomizer - Customizer を使用して、ServerHttpSecurity.HttpBasicSpec により多くのオプションを提供します。
        戻り値:
        ServerHttpSecurity をカスタマイズする
      • passwordManagement

        public ServerHttpSecurity passwordManagement​(Customizer<ServerHttpSecurity.PasswordManagementSpec> passwordManagementCustomizer)
        パスワード管理を構成します。構成例を以下に示します。
          @Bean
          public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
              http
                  // ...
                  .passwordManagement(passwordManagement ->
                        // Custom change password page.
                        passwordManagement.changePasswordPage("/custom-change-password-page")
                  );
              return http.build();
          }
         
        パラメーター:
        passwordManagementCustomizer - Customizer を使用して、ServerHttpSecurity.PasswordManagementSpec により多くのオプションを提供します。
        戻り値:
        ServerHttpSecurity をカスタマイズする
        導入:
        5.6
      • formLogin

        public ServerHttpSecurity.FormLoginSpec formLogin()
        フォームベースの認証を設定します。以下に設定例を示します。
          @Bean
          public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
              http
                  // ...
                  .formLogin()
                      // used for authenticating the credentials
                      .authenticationManager(authenticationManager)
                      // Custom persistence of the authentication
                      .securityContextRepository(securityContextRepository)
                      // expect a log in page at "/authenticate"
                      // a POST "/authenticate" is where authentication occurs
                      // error page at "/authenticate?error"
                      .loginPage("/authenticate");
              return http.build();
          }
         
        戻り値:
        ServerHttpSecurity.FormLoginSpec をカスタマイズする
      • formLogin

        public ServerHttpSecurity formLogin​(Customizer<ServerHttpSecurity.FormLoginSpec> formLoginCustomizer)
        フォームベースの認証を設定します。以下に設定例を示します。
          @Bean
          public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
              http
                  // ...
                  .formLogin((formLogin) ->
                      formLogin
                        // used for authenticating the credentials
                        .authenticationManager(authenticationManager)
                        // Custom persistence of the authentication
                        .securityContextRepository(securityContextRepository)
                        // expect a log in page at "/authenticate"
                        // a POST "/authenticate" is where authentication occurs
                        // error page at "/authenticate?error"
                        .loginPage("/authenticate")
                  );
              return http.build();
          }
         
        パラメーター:
        formLoginCustomizer - Customizer を使用して、ServerHttpSecurity.FormLoginSpec により多くのオプションを提供します。
        戻り値:
        ServerHttpSecurity をカスタマイズする
      • x509

        public ServerHttpSecurity.X509Spec x509()
        クライアントから提供された証明書を使用して x509 認証を構成します。
          @Bean
          public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
              http
                  .x509()
                        .authenticationManager(authenticationManager)
                      .principalExtractor(principalExtractor);
              return http.build();
          }
         
        エクストラクターが指定されていない場合、SubjectDnX509PrincipalExtractor が使用されることに注意してください。authenticationManager が指定されていない場合、ReactivePreAuthenticatedAuthenticationManager が使用されます。
        戻り値:
        ServerHttpSecurity.X509Spec をカスタマイズする
        導入:
        5.2
      • oauth2Login

        public ServerHttpSecurity.OAuth2LoginSpec oauth2Login()
        OAuth 2.0 または OpenID Connect 1.0 プロバイダーを使用して認証サポートを構成します。
          @Bean
          public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
              http
                  // ...
                  .oauth2Login()
                      .authenticationConverter(authenticationConverter)
                      .authenticationManager(manager);
              return http.build();
          }
         
        戻り値:
        ServerHttpSecurity.OAuth2LoginSpec をカスタマイズする
      • oauth2Login

        public ServerHttpSecurity oauth2Login​(Customizer<ServerHttpSecurity.OAuth2LoginSpec> oauth2LoginCustomizer)
        OAuth 2.0 または OpenID Connect 1.0 プロバイダーを使用して認証サポートを構成します。
          @Bean
          public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
              http
                  // ...
                  .oauth2Login((oauth2Login) ->
                      oauth2Login
                          .authenticationConverter(authenticationConverter)
                          .authenticationManager(manager)
                  );
              return http.build();
          }
         
        パラメーター:
        oauth2LoginCustomizer - Customizer を使用して、ServerHttpSecurity.OAuth2LoginSpec により多くのオプションを提供します。
        戻り値:
        ServerHttpSecurity をカスタマイズする
      • oauth2Client

        public ServerHttpSecurity.OAuth2ClientSpec oauth2Client()
        OAuth2 クライアントを構成します。
          @Bean
          public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
              http
                  // ...
                  .oauth2Client()
                      .clientRegistrationRepository(clientRegistrationRepository)
                      .authorizedClientRepository(authorizedClientRepository);
              return http.build();
          }
         
        戻り値:
        ServerHttpSecurity.OAuth2ClientSpec をカスタマイズする
      • oauth2Client

        public ServerHttpSecurity oauth2Client​(Customizer<ServerHttpSecurity.OAuth2ClientSpec> oauth2ClientCustomizer)
        OAuth2 クライアントを構成します。
          @Bean
          public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
              http
                  // ...
                  .oauth2Client((oauth2Client) ->
                      oauth2Client
                          .clientRegistrationRepository(clientRegistrationRepository)
                          .authorizedClientRepository(authorizedClientRepository)
                  );
              return http.build();
          }
         
        パラメーター:
        oauth2ClientCustomizer - Customizer を使用して、ServerHttpSecurity.OAuth2ClientSpec により多くのオプションを提供します。
        戻り値:
        ServerHttpSecurity をカスタマイズする
      • headers

        public ServerHttpSecurity.HeaderSpec headers()
        HTTP レスポンスヘッダーを構成します。デフォルトのヘッダーは次のとおりです。
         Cache-Control: no-cache, no-store, max-age=0, must-revalidate
         Pragma: no-cache
         Expires: 0
         X-Content-Type-Options: nosniff
         Strict-Transport-Security: max-age=31536000 ; includeSubDomains
         X-Frame-Options: DENY
         X-XSS-Protection: 1; mode=block
         
        そのため、"Strict-Transport-Security" は安全なリクエストにのみ追加されます。以下に設定例を示します。
          @Bean
          public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
              http
                  // ...
                  .headers()
                      // customize frame options to be same origin
                      .frameOptions()
                          .mode(XFrameOptionsServerHttpHeadersWriter.Mode.SAMEORIGIN)
                          .and()
                      // disable cache control
                      .cache().disable();
              return http.build();
          }
         
        戻り値:
        ServerHttpSecurity.HeaderSpec をカスタマイズする
      • headers

        public ServerHttpSecurity headers​(Customizer<ServerHttpSecurity.HeaderSpec> headerCustomizer)
        HTTP レスポンスヘッダーを構成します。デフォルトのヘッダーは次のとおりです。
         Cache-Control: no-cache, no-store, max-age=0, must-revalidate
         Pragma: no-cache
         Expires: 0
         X-Content-Type-Options: nosniff
         Strict-Transport-Security: max-age=31536000 ; includeSubDomains
         X-Frame-Options: DENY
         X-XSS-Protection: 1; mode=block
         
        そのため、"Strict-Transport-Security" は安全なリクエストにのみ追加されます。以下に設定例を示します。
          @Bean
          public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
              http
                  // ...
                  .headers((headers) ->
                      headers
                          // customize frame options to be same origin
                          .frameOptions((frameOptions) ->
                              frameOptions
                                  .mode(XFrameOptionsServerHttpHeadersWriter.Mode.SAMEORIGIN)
                           )
                          // disable cache control
                          .cache((cache) ->
                              cache
                                  .disable()
                          )
                  );
              return http.build();
          }
         
        パラメーター:
        headerCustomizer - Customizer を使用して、ServerHttpSecurity.HeaderSpec により多くのオプションを提供します。
        戻り値:
        ServerHttpSecurity をカスタマイズする
      • exceptionHandling

        public ServerHttpSecurity.ExceptionHandlingSpec exceptionHandling()
        例外処理を構成します(つまり、認証がリクエストされたときに処理します)。以下に設定例を示します。
          @Bean
          public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
              http
                  // ...
                  .exceptionHandling()
                      // customize how to request for authentication
                      .authenticationEntryPoint(entryPoint);
              return http.build();
          }
         
        戻り値:
        ServerHttpSecurity.ExceptionHandlingSpec をカスタマイズする
      • exceptionHandling

        public ServerHttpSecurity exceptionHandling​(Customizer<ServerHttpSecurity.ExceptionHandlingSpec> exceptionHandlingCustomizer)
        例外処理を構成します(つまり、認証がリクエストされたときに処理します)。以下に設定例を示します。
          @Bean
          public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
              http
                  // ...
                  .exceptionHandling((exceptionHandling) ->
                      exceptionHandling
                          // customize how to request for authentication
                          .authenticationEntryPoint(entryPoint)
                  );
              return http.build();
          }
         
        パラメーター:
        exceptionHandlingCustomizer - Customizer を使用して、ServerHttpSecurity.ExceptionHandlingSpec により多くのオプションを提供します。
        戻り値:
        ServerHttpSecurity をカスタマイズする
      • authorizeExchange

        public ServerHttpSecurity.AuthorizeExchangeSpec authorizeExchange()
        認可を構成します。以下に設定例を示します。
          @Bean
          public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
              http
                  // ...
                  .authorizeExchange()
                      // any URL that starts with /admin/ requires the role "ROLE_ADMIN"
                      .pathMatchers("/admin/**").hasRole("ADMIN")
                      // a POST to /users requires the role "USER_POST"
                      .pathMatchers(HttpMethod.POST, "/users").hasAuthority("USER_POST")
                      // a request to /users/{username} requires the current authentication's username
                      // to be equal to the {username}
                      .pathMatchers("/users/{username}").access((authentication, context) ->
                          authentication
                              .map(Authentication::getName)
                              .map((username) -> username.equals(context.getVariables().get("username")))
                              .map(AuthorizationDecision::new)
                      )
                      // allows providing a custom matching strategy that requires the role "ROLE_CUSTOM"
                      .matchers(customMatcher).hasRole("CUSTOM")
                      // any other request requires the user to be authenticated
                      .anyExchange().authenticated();
              return http.build();
          }
         
        戻り値:
        ServerHttpSecurity.AuthorizeExchangeSpec をカスタマイズする
      • authorizeExchange

        public ServerHttpSecurity authorizeExchange​(Customizer<ServerHttpSecurity.AuthorizeExchangeSpec> authorizeExchangeCustomizer)
        認可を構成します。以下に設定例を示します。
          @Bean
          public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
              http
                  // ...
                  .authorizeExchange((exchanges) ->
                      exchanges
                          // any URL that starts with /admin/ requires the role "ROLE_ADMIN"
                          .pathMatchers("/admin/**").hasRole("ADMIN")
                          // a POST to /users requires the role "USER_POST"
                          .pathMatchers(HttpMethod.POST, "/users").hasAuthority("USER_POST")
                          // a request to /users/{username} requires the current authentication's username
                          // to be equal to the {username}
                          .pathMatchers("/users/{username}").access((authentication, context) ->
                              authentication
                                  .map(Authentication::getName)
                                  .map((username) -> username.equals(context.getVariables().get("username")))
                                  .map(AuthorizationDecision::new)
                          )
                          // allows providing a custom matching strategy that requires the role "ROLE_CUSTOM"
                          .matchers(customMatcher).hasRole("CUSTOM")
                          // any other request requires the user to be authenticated
                          .anyExchange().authenticated()
                  );
              return http.build();
          }
         
        パラメーター:
        authorizeExchangeCustomizer - Customizer を使用して、ServerHttpSecurity.AuthorizeExchangeSpec により多くのオプションを提供します。
        戻り値:
        ServerHttpSecurity をカスタマイズする
      • logout

        public ServerHttpSecurity.LogoutSpec logout()
        ログアウトを構成します。以下に設定例を示します。
          @Bean
          public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
              http
                  // ...
                  .logout()
                      // configures how log out is done
                      .logoutHandler(logoutHandler)
                      // log out will be performed on POST /signout
                      .logoutUrl("/signout")
                      // configure what is done on logout success
                      .logoutSuccessHandler(successHandler);
              return http.build();
          }
         
        戻り値:
        ServerHttpSecurity.LogoutSpec をカスタマイズする
      • logout

        public ServerHttpSecurity logout​(Customizer<ServerHttpSecurity.LogoutSpec> logoutCustomizer)
        ログアウトを構成します。以下に設定例を示します。
          @Bean
          public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
              http
                  // ...
                  .logout((logout) ->
                      logout
                          // configures how log out is done
                          .logoutHandler(logoutHandler)
                          // log out will be performed on POST /signout
                          .logoutUrl("/signout")
                          // configure what is done on logout success
                          .logoutSuccessHandler(successHandler)
                  );
              return http.build();
          }
         
        パラメーター:
        logoutCustomizer - Customizer を使用して、ServerHttpSecurity.LogoutSpec により多くのオプションを提供します。
        戻り値:
        ServerHttpSecurity をカスタマイズする
      • requestCache

        public ServerHttpSecurity.RequestCacheSpec requestCache()
        リクエストが認証後にリプレイできるように、フローが中断されたときに(つまり、資格情報をリクエストしたために)使用されるリクエストキャッシュを構成します。以下に設定例を示します。
          @Bean
          public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
              http
                  // ...
                  .requestCache()
                      // configures how the request is cached
                      .requestCache(requestCache);
              return http.build();
          }
         
        戻り値:
        ServerHttpSecurity.RequestCacheSpec をカスタマイズする
      • requestCache

        public ServerHttpSecurity requestCache​(Customizer<ServerHttpSecurity.RequestCacheSpec> requestCacheCustomizer)
        リクエストが認証後にリプレイできるように、フローが中断されたときに(つまり、資格情報をリクエストしたために)使用されるリクエストキャッシュを構成します。以下に設定例を示します。
          @Bean
          public SecurityWebFilterChain springSecurityFilterChain(ServerHttpSecurity http) {
              http
                  // ...
                  .requestCache((requestCache) ->
                      requestCache
                          // configures how the request is cached
                          .requestCache(customRequestCache)
                  );
              return http.build();
          }
         
        パラメーター:
        requestCacheCustomizer - Customizer を使用して、ServerHttpSecurity.RequestCacheSpec により多くのオプションを提供します。
        戻り値:
        ServerHttpSecurity をカスタマイズする
      • authenticationManager

        public ServerHttpSecurity authenticationManager​(ReactiveAuthenticationManager manager)
        デフォルトの認証マネージャーを構成します。
        パラメーター:
        manager - 使用する認証マネージャー
        戻り値:
        ServerHttpSecurity をカスタマイズする
      • setApplicationContext

        protected void setApplicationContext​(org.springframework.context.ApplicationContext applicationContext)
                                      throws org.springframework.beans.BeansException
        例外:
        org.springframework.beans.BeansException