Class JWTAuthenticator

  • All Implemented Interfaces:
    NuxeoAuthenticationPlugin

    public class JWTAuthenticator
    extends Object
    implements NuxeoAuthenticationPlugin
    JSON Web Token (JWT) Authentication Plugin.

    The Authorization Bearer token from the headers is checked with the JWTService for validity, and if it is valid the authentication is done for the token's subject.

    If an "aud" claim (JWTClaims.CLAIM_AUDIENCE) is present in the token, it must be a prefix of the request HTTP path info (excluding the web context). This allows limiting tokens for specific URL patterns.

    Since:
    10.3
    • Constructor Detail

      • JWTAuthenticator

        public JWTAuthenticator()
    • Method Detail

      • handleLoginPrompt

        public Boolean handleLoginPrompt​(javax.servlet.http.HttpServletRequest httpRequest,
                                         javax.servlet.http.HttpServletResponse httpResponse,
                                         String baseURL)
        Description copied from interface: NuxeoAuthenticationPlugin
        Handles the Login Prompt.
        Specified by:
        handleLoginPrompt in interface NuxeoAuthenticationPlugin
        Parameters:
        httpRequest - the request
        httpResponse - the response
        Returns:
        true if AuthFilter must stop execution (ie: login prompt generated a redirect), false otherwise
      • retrieveToken

        protected String retrieveToken​(javax.servlet.http.HttpServletRequest request)
      • getRequestPath

        protected static String getRequestPath​(javax.servlet.http.HttpServletRequest request)
        Gets the request path. The returned value never starts nor ends with a slash.
      • isEqualOrPathPrefix

        protected static boolean isEqualOrPathPrefix​(String path,
                                                     String prefix)
        Compares path-wise a path with a prefix.