-
-
Notifications
You must be signed in to change notification settings - Fork 4k
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
ReactiveSecurityContextHolder.getContext() is empty , unable to getCurrentUserLogin() in any service except Gateway #27934
Comments
@deceivingrakesh can you provide a PR with the change? |
I don't have the solution for the problem yet , I'm still not able to get current logged in userId from microservices , other than gateway by using the getCurrentUserLogin() , when I debugged I got to know that ReactiveSecurityContextHolder.getContext() is returning empty inside the getCurrentUserLogin() method . |
Is there any update on this issue , as of now I'm using Principal object in controller to get UserId . |
No update. But if you figure out a solution, please let us know. I'll add a bug bounty to see if that helps get this fixed. |
Can someone provide example to reproduce this bug? @mraible @deceivingrakesh |
@kamilkrzywanski , Generate a new reactive microservice app , and try to get the current logged in username with SecurityUtils.getCurrentUserLogin() method , it's returns empty . It works in Gateway app , but not in any other service . |
@kamilkrzywanski , you are right , If I return a mono , value is present , but if I subscribe to the Mono , I'm unable to use / print it , I guess I'm missing something with reactive / Mono . @GetMapping(value = "/login", produces = MediaType.APPLICATION_JSON_VALUE) This , SecurityUtils.getCurrentUserLogin().hasElement().subscribe(tof -> LOG.info(tof.toString())); Logs False in console . Can you help me with this ? |
Can you try with { |
@deceivingrakesh |
@kamilkrzywanski it worked for me now , I was doing it wrong , followed your code , This isn't a defect . |
Overview of the issue
Unable to fetch current loggedin user from a reactive microservice using the getCurrentUserLogin() method , except it works in Gateway
Motivation for or Use Case
Need to use current logged in user details in different services
Reproduce the error
When I changed the method getCurrentUserLogin() in SecurityUtils class to
the context is empty .
Related issues
Suggest a Fix
JHipster Version(s)
8.7.3
Browsers and Operating System
The text was updated successfully, but these errors were encountered: