-
Notifications
You must be signed in to change notification settings - Fork 4
Open
Description
Hello, Thank you for the great work. Could you please add spring security support with this example. I have tried using spring-security-rsocket and configuring PayloadSocketAcceptorInterceptor but is does not work.
Here is my security config:
@Configuration
@EnableRSocketSecurity
public class RsocketSecurityConfig {
@Bean
PayloadSocketAcceptorInterceptor rsocketInterceptor(RSocketSecurity rsocket) {
return rsocket
.authorizePayload(authorize ->
authorize
.route("*").authenticated()
.anyRequest().authenticated()
.anyExchange().authenticated()
).jwt(jwtSpec -> {
try {
jwtSpec.authenticationManager(jwtReactiveAuthenticationManager(reactiveJwtDecoder()));
} catch (Exception e) {
throw new RuntimeException(e);
}
}).build();
}
@Bean
ReactiveJwtDecoder reactiveJwtDecoder() {
return ReactiveJwtDecoders
.fromIssuerLocation("http://localhost:7475/auth/realms/devnation");
}
@Bean
public JwtReactiveAuthenticationManager jwtReactiveAuthenticationManager(ReactiveJwtDecoder reactiveJwtDecoder) {
JwtReactiveAuthenticationManager jwtReactiveAuthenticationManager = new JwtReactiveAuthenticationManager(reactiveJwtDecoder);
JwtAuthenticationConverter authenticationConverter = new JwtAuthenticationConverter();
JwtGrantedAuthoritiesConverter jwtGrantedAuthoritiesConverter = new JwtGrantedAuthoritiesConverter();
jwtGrantedAuthoritiesConverter.setAuthorityPrefix("ROLE_");
authenticationConverter.setJwtGrantedAuthoritiesConverter(jwtGrantedAuthoritiesConverter);
jwtReactiveAuthenticationManager.setJwtAuthenticationConverter( new ReactiveJwtAuthenticationConverterAdapter(authenticationConverter));
return jwtReactiveAuthenticationManager;
}
}
I am still able to call hello-service methods from hello-client without any token. There is no error thrown.
Metadata
Metadata
Assignees
Labels
No labels