How to get SecurityContext in spring security webflux

6.7k Views Asked by At

In traditional Spring web applications, it is easy to get a SecurityContext from SecurityContextHolder, but when I used spring-security-webflux(Spring Security 5.0.O.M3) in a spring-webflux application, it seems Spring Security did not store SecurityContext into SecurityContextHolder for every requests.

Or in other words, is there an easy way to get current authentication info outside of WebHanlder/Controllers? I wan to implement AuditorAware interface to get auditing(auto fills the current user) for Spring Data MongoDB.

Update: Spring Security 5.0.0.RELEASE provides a ReactiveSecurityContextHolder to archive this purpose.

0

There are 0 best solutions below