In order to access the SecurityContext in the new reactive Spring Security module, we have a new class called ReactiveSecurityContextHolder.
ReactiveSecurityContextHolder provides access to the current SecurityContext in a reactive manner over a static getContext method, which returns Mono<SecurityContext>. This means that we can write the following code in order to access SecurityContext in the application:
@RestController // (1)@RequestMapping("/api/v1") //public class SecuredProfileController { // @GetMapping("/profiles") // (2) @PreAuthorize("hasRole(USER)") // (2.1) public Mono<Profile> getProfile() { // (2.2) return ReactiveSecurityContextHolder // (2.3) .getContext() // (2.4) .map(SecurityContext ...