Class SecurityContextHolder

java.lang.Object
io.micronaut.security.context.SecurityContextHolder

public final class SecurityContextHolder extends Object
Access point for the SecurityContext associated with the current server request.

The returned context is backed by request attributes populated by the security filter.

Since:
4.18.0
  • Method Details

    • getSecurityContext

      @NonNull public static @NonNull SecurityContext getSecurityContext()
      Returns a SecurityContext for the current request.
      Returns:
      a SecurityContext backed by the current request, or an empty context if no request is active
    • clearContext

      public static void clearContext()
      Clears the security context associated with the current request.