Class RSocketSecurity
- java.lang.Object
-
- org.springframework.security.config.annotation.rsocket.RSocketSecurity
-
public class RSocketSecurity extends java.lang.ObjectAllows configuring RSocket based security. A minimal example can be found below:@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 }- Since:
- 5.2
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description classRSocketSecurity.AuthorizePayloadsSpecclassRSocketSecurity.BasicAuthenticationSpecclassRSocketSecurity.JwtSpec
-
Constructor Summary
Constructors Constructor Description RSocketSecurity()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description RSocketSecurityaddPayloadInterceptor(PayloadInterceptor interceptor)Adds aPayloadInterceptorto be used.RSocketSecurityauthenticationManager(ReactiveAuthenticationManager authenticationManager)RSocketSecurityauthorizePayload(Customizer<RSocketSecurity.AuthorizePayloadsSpec> authorize)RSocketSecuritybasicAuthentication(Customizer<RSocketSecurity.BasicAuthenticationSpec> basic)PayloadSocketAcceptorInterceptorbuild()RSocketSecurityjwt(Customizer<RSocketSecurity.JwtSpec> jwt)protected voidsetApplicationContext(org.springframework.context.ApplicationContext applicationContext)
-
-
-
Method Detail
-
addPayloadInterceptor
public RSocketSecurity addPayloadInterceptor(PayloadInterceptor interceptor)
Adds aPayloadInterceptorto be used. This is typically only used when using the DSL does not meet a users needs. In order to ensure thePayloadInterceptoris done in the proper order thePayloadInterceptorshould either implementOrderedor be annotated withOrder.- Parameters:
interceptor-- Returns:
- the builder for additional customizations
- See Also:
PayloadInterceptorOrder
-
authenticationManager
public RSocketSecurity authenticationManager(ReactiveAuthenticationManager authenticationManager)
-
basicAuthentication
public RSocketSecurity basicAuthentication(Customizer<RSocketSecurity.BasicAuthenticationSpec> basic)
-
jwt
public RSocketSecurity jwt(Customizer<RSocketSecurity.JwtSpec> jwt)
-
authorizePayload
public RSocketSecurity authorizePayload(Customizer<RSocketSecurity.AuthorizePayloadsSpec> authorize)
-
build
public PayloadSocketAcceptorInterceptor build()
-
setApplicationContext
protected void setApplicationContext(org.springframework.context.ApplicationContext applicationContext) throws org.springframework.beans.BeansException- Throws:
org.springframework.beans.BeansException
-
-