1
0
mirror of synced 2026-07-20 01:55:08 +00:00

Add Hello RSocket Sample

Fixes gh-7504
This commit is contained in:
Rob Winch
2019-09-30 13:57:52 -05:00
parent 83b5f5c7ae
commit 03e2efacf4
7 changed files with 248 additions and 0 deletions
@@ -4,6 +4,12 @@
Spring Security's RSocket support relies on a `SocketAcceptorInterceptor`.
The main entry point into security is found in the `PayloadSocketAcceptorInterceptor` which adapts the RSocket APIs to allow intercepting a `PayloadExchange` with `PayloadInterceptor` implementations.
You can find a few sample applications that demonstrate the code below:
* Hello RSocket {gh-samples-url}/boot/hellorsocket[hellorsocket]
* https://github.com/rwinch/spring-flights/tree/security[Spring Flights]
== Minimal RSocket Security Configuration
You can find a minimal RSocket Security configuration below:
@@ -28,6 +34,21 @@ public class HelloRSocketSecurityConfig {
This configuration enables <<rsocket-authentication-basic,basic authentication>> and sets up <<authorization,rsocket-authorization>> to require an authenticated user for any request.
== Adding SecuritySocketAcceptorInterceptor
For Spring Security to work we need to apply `SecuritySocketAcceptorInterceptor` to the `ServerRSocketFactory`.
This is what connects our `PayloadSocketAcceptorInterceptor` we created with the RSocket infrastructure.
In a Spring Boot application this can be done using the following code.
[source,java]
----
@Bean
ServerRSocketFactoryCustomizer springSecurityRSocketSecurity(
SecuritySocketAcceptorInterceptor interceptor) {
return builder -> builder.addSocketAcceptorPlugin(interceptor);
}
----
[[rsocket-authentication]]
== RSocket Authentication