val messageByUsername: Mono = ReactiveSecurityContextHolder.getContext() .map(SecurityContext::getAuthentication) .map(Authentication::getName)

always returns null, even when authentication has been done.

Code for authentication : return webFilterChain.filter(serverWebExchange).contextWrite { var cont = ReactiveSecurityContextHolder.withSecurityContext( Mono.just( SecurityContextImpl( injectSecurityPrincipal(reqHeaders[USER_ID_ATTRIBUTE]!!.first(), scopes) ) ) )

Comment From: sjohnr

Duplicate of gh-11721.