クラス RSocketSecurity
java.lang.ObjectSE
org.springframework.security.config.annotation.rsocket.RSocketSecurity
RSocket ベースのセキュリティを設定できます。最小限の例を以下に示します。
@Configuration @EnableRSocketSecurity public class SecurityConfig { @Bean PayloadSocketAcceptorInterceptor rsocketInterceptor(RSocketSecurity rsocket) { rsocket .authorizePayload((authorize) -> authorize .anyRequest().authenticated() ); return rsocket.build(); } @Bean public MapReactiveUserDetailsService userDetailsService() { UserDetails user = User.withDefaultPasswordEncoder() .username("user") .password("password") .roles("USER") .build(); return new MapReactiveUserDetailsService(user); } }より高度な構成を以下に示します。
@Configuration @EnableRSocketSecurity public class SecurityConfig { @Bean PayloadSocketAcceptorInterceptor rsocketInterceptor(RSocketSecurity rsocket) { rsocket .authorizePayload((authorize) -> authorize // must have ROLE_SETUP to make connection .setup().hasRole("SETUP") // must have ROLE_ADMIN for routes starting with "admin." .route("admin.*").hasRole("ADMIN") // any other request must be authenticated for .anyRequest().authenticated() ); return rsocket.build(); } }
- 導入:
- 5.2
ネストされたクラスのサマリー
ネストされたクラス修飾子と型クラス説明class
final class
final class
final class
コンストラクターの概要
コンストラクターメソッドのサマリー
修飾子と型メソッド説明addPayloadInterceptor
(PayloadInterceptor interceptor) 使用するPayloadInterceptor
を追加します。authenticationManager
(ReactiveAuthenticationManager authenticationManager) 使用すべきではありません。build()
protected void
setApplicationContext
(org.springframework.context.ApplicationContext applicationContext) 単純認証を使用してユーザー名とパスワードを検証するためのサポートを追加します
コンストラクターの詳細
RSocketSecurity
public RSocketSecurity()
メソッドの詳細
addPayloadInterceptor
使用するPayloadInterceptor
を追加します。これは通常、DSL の使用がユーザーのニーズを満たさない場合にのみ使用されます。PayloadInterceptor
が適切な順序で実行されるようにするために、PayloadInterceptor
はOrdered
を実装するか、Order
でアノテーションを付ける必要があります。- パラメーター:
interceptor
-- 戻り値:
- 追加のカスタマイズのためのビルダー
- 関連事項:
authenticationManager
simpleAuthentication
public RSocketSecurity simpleAuthentication(Customizer<RSocketSecurity.SimpleAuthenticationSpec> simple) 単純認証を使用してユーザー名とパスワードを検証するためのサポートを追加します- パラメーター:
simple
- カスタマイザ- 戻り値:
- 追加構成のための RSocketSecurity
- 導入:
- 5.3
basicAuthentication
@DeprecatedSE public RSocketSecurity basicAuthentication(Customizer<RSocketSecurity.BasicAuthenticationSpec> basic) 使用すべきではありません。BasicAuthenticationPayloadExchangeConverter による認証を追加します。- パラメーター:
basic
-- 戻り値:
- このインスタンス
jwt
authorizePayload
public RSocketSecurity authorizePayload(Customizer<RSocketSecurity.AuthorizePayloadsSpec> authorize) build
setApplicationContext
protected void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException - 例外:
org.springframework.beans.BeansException
simpleAuthentication(Customizer)
を使用