public class RSocketSecurity
extends java.lang.Object
@EnableRSocketSecurity
public class SecurityConfig {
// @formatter:off
@Bean
PayloadSocketAcceptorInterceptor rsocketInterceptor(RSocketSecurity rsocket) {
rsocket
.authorizePayload(authorize ->
authorize
.anyRequest().authenticated()
);
return rsocket.build();
}
// @formatter:on
// @formatter:off
@Bean
public MapReactiveUserDetailsService userDetailsService() {
UserDetails user = User.withDefaultPasswordEncoder()
.username("user")
.password("password")
.roles("USER")
.build();
return new MapReactiveUserDetailsService(user);
}
// @formatter:on
}
より高度な構成を以下に示します。
@EnableRSocketSecurity
public class SecurityConfig {
// @formatter:off
@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();
}
// @formatter:on
}
| 修飾子と型 | クラスと説明 |
|---|---|
class | RSocketSecurity.AuthorizePayloadsSpec |
class | RSocketSecurity.BasicAuthenticationSpec |
class | RSocketSecurity.JwtSpec |
class | RSocketSecurity.SimpleAuthenticationSpec |
| コンストラクターと説明 |
|---|
RSocketSecurity() |
| 修飾子と型 | メソッドと説明 |
|---|---|
RSocketSecurity | addPayloadInterceptor(PayloadInterceptor interceptor) 使用する PayloadInterceptor を追加します。 |
RSocketSecurity | authenticationManager(ReactiveAuthenticationManager authenticationManager) |
RSocketSecurity | authorizePayload(Customizer<RSocketSecurity.AuthorizePayloadsSpec> authorize) |
RSocketSecurity | basicAuthentication(Customizer<RSocketSecurity.BasicAuthenticationSpec> basic) 使用すべきではありません。 |
PayloadSocketAcceptorInterceptor | build() |
RSocketSecurity | jwt(Customizer<RSocketSecurity.JwtSpec> jwt) |
protected void | setApplicationContext(org.springframework.context.ApplicationContext applicationContext) |
RSocketSecurity | simpleAuthentication(Customizer<RSocketSecurity.SimpleAuthenticationSpec> simple)単純認証を使用してユーザー名とパスワードを検証するためのサポートを追加します |
public RSocketSecurity addPayloadInterceptor(PayloadInterceptor interceptor)
PayloadInterceptor を追加します。これは通常、DSL の使用がユーザーのニーズを満たさない場合にのみ使用されます。PayloadInterceptor が適切な順序で実行されるようにするために、PayloadInterceptor は Ordered を実装するか、Order でアノテーションを付ける必要があります。interceptor -PayloadInterceptorOrderpublic RSocketSecurity authenticationManager(ReactiveAuthenticationManager authenticationManager)
public RSocketSecurity simpleAuthentication(Customizer<RSocketSecurity.SimpleAuthenticationSpec> simple)
simple - カスタマイザ @Deprecated public RSocketSecurity basicAuthentication(Customizer<RSocketSecurity.BasicAuthenticationSpec> basic)
basic -public RSocketSecurity jwt(Customizer<RSocketSecurity.JwtSpec> jwt)
public RSocketSecurity authorizePayload(Customizer<RSocketSecurity.AuthorizePayloadsSpec> authorize)
public PayloadSocketAcceptorInterceptor build()
protected void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
throws org.springframework.beans.BeansExceptionorg.springframework.beans.BeansException