Browse Source

Add Kotlin example for SecuritySocketAcceptorInterceptor of RSocket

Closes gh-10932
Lijamaija 3 years ago
parent
commit
bc2bb8cb96
1 changed files with 17 additions and 1 deletions
  1. 17 1
      docs/modules/ROOT/pages/reactive/integrations/rsocket.adoc

+ 17 - 1
docs/modules/ROOT/pages/reactive/integrations/rsocket.adoc

@@ -61,7 +61,9 @@ For Spring Security to work we need to apply `SecuritySocketAcceptorInterceptor`
 This is what connects our `PayloadSocketAcceptorInterceptor` we created with the RSocket infrastructure.
 In a Spring Boot application this is done automatically using `RSocketSecurityAutoConfiguration` with the following code.
 
-[source,java]
+====
+.Java
+[source,java,role="primary"]
 ----
 @Bean
 RSocketServerCustomizer springSecurityRSocketSecurity(SecuritySocketAcceptorInterceptor interceptor) {
@@ -69,6 +71,20 @@ RSocketServerCustomizer springSecurityRSocketSecurity(SecuritySocketAcceptorInte
 }
 ----
 
+.Kotlin
+[source,kotlin,role="secondary"]
+----
+@Bean
+fun springSecurityRSocketSecurity(interceptor: SecuritySocketAcceptorInterceptor): RSocketServerCustomizer {
+    return RSocketServerCustomizer { server ->
+        server.interceptors { registry ->
+            registry.forSocketAcceptor(interceptor)
+        }
+    }
+}
+----
+====
+
 [[rsocket-authentication]]
 == RSocket Authentication