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 }A more advanced configuration can be seen below:
@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 }
Modifier and Type | Class and Description |
---|---|
class |
RSocketSecurity.AuthorizePayloadsSpec |
class |
RSocketSecurity.BasicAuthenticationSpec |
class |
RSocketSecurity.JwtSpec |
class |
RSocketSecurity.SimpleAuthenticationSpec |
Constructor and Description |
---|
RSocketSecurity() |
Modifier and Type | Method and Description |
---|---|
RSocketSecurity |
addPayloadInterceptor(PayloadInterceptor interceptor)
Adds a
PayloadInterceptor to be used. |
RSocketSecurity |
authenticationManager(ReactiveAuthenticationManager authenticationManager) |
RSocketSecurity |
authorizePayload(Customizer<RSocketSecurity.AuthorizePayloadsSpec> authorize) |
RSocketSecurity |
basicAuthentication(Customizer<RSocketSecurity.BasicAuthenticationSpec> basic)
Deprecated.
|
PayloadSocketAcceptorInterceptor |
build() |
RSocketSecurity |
jwt(Customizer<RSocketSecurity.JwtSpec> jwt) |
protected void |
setApplicationContext(org.springframework.context.ApplicationContext applicationContext) |
RSocketSecurity |
simpleAuthentication(Customizer<RSocketSecurity.SimpleAuthenticationSpec> simple)
Adds support for validating a username and password using
Simple Authentication
|
public RSocketSecurity addPayloadInterceptor(PayloadInterceptor interceptor)
PayloadInterceptor
to be used. This is typically only used
when using the DSL does not meet a users needs. In order to ensure the
PayloadInterceptor
is done in the proper order the PayloadInterceptor
should
either implement Ordered
or be annotated with
Order
.interceptor
- PayloadInterceptorOrder
public RSocketSecurity authenticationManager(ReactiveAuthenticationManager authenticationManager)
public RSocketSecurity simpleAuthentication(Customizer<RSocketSecurity.SimpleAuthenticationSpec> simple)
simple
- a customizer@Deprecated public RSocketSecurity basicAuthentication(Customizer<RSocketSecurity.BasicAuthenticationSpec> basic)
simpleAuthentication(Customizer)
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.BeansException
org.springframework.beans.BeansException