소스 검색

Add Kotlin example for SecuritySocketAcceptorInterceptor of RSocket

Closes gh-10932
Lijamaija 3 년 전
부모
커밋
bc2bb8cb96
1개의 변경된 파일17개의 추가작업 그리고 1개의 파일을 삭제
  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