Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Reactive Messaging AuthenticationPrincipalArgumentResolver #7363

Closed
rwinch opened this issue Sep 5, 2019 · 1 comment
Closed

Add Reactive Messaging AuthenticationPrincipalArgumentResolver #7363

rwinch opened this issue Sep 5, 2019 · 1 comment
Assignees
Labels
in: messaging An issue in spring-security-messaging type: enhancement A general enhancement
Milestone

Comments

@rwinch
Copy link
Member

rwinch commented Sep 5, 2019

Summary

We should be able to use an argument resolver for the RSocket Support in Spring

@rwinch rwinch added type: enhancement A general enhancement in: rsocket labels Sep 5, 2019
@rwinch rwinch added this to the 5.2.0 milestone Sep 5, 2019
@rwinch rwinch self-assigned this Sep 5, 2019
@rwinch rwinch changed the title Add RSocket Argument Resolver Support Add Reactive Messaging AuthenticationPrincipalArgumentResolver Sep 24, 2019
@rwinch rwinch added in: messaging An issue in spring-security-messaging and removed in: rsocket labels Sep 24, 2019
@rwinch rwinch closed this as completed in b09e9f1 Sep 24, 2019
rwinch added a commit that referenced this issue Sep 24, 2019
AuthenticationPrincipalArgumentResolverTests failed in JDK 9+ due to
its improved generic support and a ClassCastException.

Issue gh-7363
@nofelkad
Copy link

Adding @AuthenticationPrincipal to messageMapping method gives

java.lang.NullPointerException
	at io.rsocket.util.ByteBufPayload.sliceData(ByteBufPayload.java:149)
	Suppressed: reactor.core.publisher.FluxOnAssembly$OnAssemblyException: 
Assembly trace from producer [reactor.core.publisher.FluxMapFuseable] :
	reactor.core.publisher.Flux.map(Flux.java:5892)
	org.springframework.messaging.rsocket.annotation.support.MessagingRSocket.handleAndReply(MessagingRSocket.java:170)
Error has been observed at the following site(s):
	|_            Flux.map ⇢ at org.springframework.messaging.rsocket.annotation.support.MessagingRSocket.handleAndReply(MessagingRSocket.java:170)
	|_  Flux.doOnSubscribe ⇢ at org.springframework.messaging.rsocket.annotation.support.MessagingRSocket.handleAndReply(MessagingRSocket.java:170)
	|_            Flux.map ⇢ at org.springframework.messaging.handler.annotation.reactive.PayloadMethodArgumentResolver.extractContent(PayloadMethodArgumentResolver.java:178)
	|_           Flux.next ⇢ at org.springframework.messaging.handler.annotation.reactive.PayloadMethodArgumentResolver.decodeContent(PayloadMethodArgumentResolver.java:247)
	|_            Mono.map ⇢ at org.springframework.messaging.handler.annotation.reactive.PayloadMethodArgumentResolver.decodeContent(PayloadMethodArgumentResolver.java:248)
	|_          Mono.error ⇢ at org.springframework.messaging.handler.annotation.reactive.PayloadMethodArgumentResolver.lambda$decodeContent$5(PayloadMethodArgumentResolver.java:249)
	|_  Mono.onErrorResume ⇢ at org.springframework.messaging.handler.annotation.reactive.PayloadMethodArgumentResolver.decodeContent(PayloadMethodArgumentResolver.java:249)
	|_  Mono.switchIfEmpty ⇢ at org.springframework.messaging.handler.annotation.reactive.PayloadMethodArgumentResolver.decodeContent(PayloadMethodArgumentResolver.java:251)
	|_ Mono.defaultIfEmpty ⇢ at org.springframework.messaging.handler.invocation.reactive.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:184)
	|_      Mono.doOnError ⇢ at org.springframework.messaging.handler.invocation.reactive.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:185)
	|_            Mono.zip ⇢ at org.springframework.messaging.handler.invocation.reactive.InvocableHandlerMethod.getMethodArgumentValues(InvocableHandlerMethod.java:192)
	|_        Mono.flatMap ⇢ at org.springframework.messaging.handler.invocation.reactive.InvocableHandlerMethod.invoke(InvocableHandlerMethod.java:128)
	|_  Mono.switchIfEmpty ⇢ at org.springframework.messaging.handler.invocation.reactive.InvocableHelper.handleMessage(InvocableHelper.java:195)
	|_        Mono.flatMap ⇢ at org.springframework.messaging.handler.invocation.reactive.InvocableHelper.handleMessage(InvocableHelper.java:196)
	|_          Mono.error ⇢ at org.springframework.messaging.handler.invocation.reactive.InvocableHelper.lambda$handleMessage$4(InvocableHelper.java:200)
	|_  Mono.onErrorResume ⇢ at org.springframework.messaging.handler.invocation.reactive.InvocableHelper.handleMessage(InvocableHelper.java:197)
	|_          Mono.defer ⇢ at org.springframework.messaging.rsocket.annotation.support.MessagingRSocket.handleAndReply(MessagingRSocket.java:173)
	|_      Mono.doFinally ⇢ at org.springframework.messaging.rsocket.annotation.support.MessagingRSocket.handleAndReply(MessagingRSocket.java:174)
	|_       Mono.thenMany ⇢ at org.springframework.messaging.rsocket.annotation.support.MessagingRSocket.handleAndReply(MessagingRSocket.java:180)
	|_       Mono.thenMany ⇢ at org.springframework.messaging.rsocket.annotation.support.MessagingRSocket.handleAndReply(MessagingRSocket.java:180)
	|_       Mono.thenMany ⇢ at org.springframework.messaging.rsocket.annotation.support.MessagingRSocket.handleAndReply(MessagingRSocket.java:180)
	|_           Flux.next ⇢ at org.springframework.messaging.rsocket.annotation.support.MessagingRSocket.requestResponse(MessagingRSocket.java:122)
	|_        Mono.flatMap ⇢ at org.springframework.security.rsocket.core.PayloadInterceptorRSocket.requestResponse(PayloadInterceptorRSocket.java:84)

I followed this for jwt with spring boot 2.2.2.RELEASE.

Although, i can see ReactiveSecurityContextHolder getting set with authentication object onAuthenticationSuccess but it's empty when tried getting the same in the controller method.

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: messaging An issue in spring-security-messaging type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

2 participants