I am working on bringing WebSockets functionality to my Grails application. I use Atmosphere Meteor plugin 0.7.1 for this purpose. The workflow is simple:
I would like to know which user connected my webSocket.
Usually it's quite easy to detect current user by calling springSecurityService.getPrincipal()
in any controller. I managed to inject springSecurityService
to my MeteorHandler, however it says that the principal is null
. It feels strange for me, as the handler has access to JSESSIONID
cookie, so I expect it to retrieve the correct session data.
Also, request.session
command returns different HttpSession object, compared to the same command performed in regular controller action.
So is there any way to retrieve current logged in user on webSockets connection?
Thanks in advance.
The Principal object could be easily retrieved from request.userPrincipal.principal
It is exactly the same object as in springSecurityService.getPrincipal()
Find more here: https://github.com/kensiprell/grails-atmosphere-meteor/issues/28#issuecomment-34629462
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With