java.lang.Object
io.helidon.security.providers.jwt.JwtProvider
All Implemented Interfaces:
AuthenticationProvider, OutboundSecurityProvider, SecurityProvider

public final class JwtProvider extends Object implements AuthenticationProvider, OutboundSecurityProvider
Provider that can process JWT tokens in request headers and assert identity (e.g. create a Principal for a SubjectType.USER or SubjectType.SERVICE. This provider can also propagate identity using JWT token, either by creating a new JWT or by propagating the existing token "as is". Verification and signatures of tokens is done through JWK standard - two separate JWK files are expected (one for verification, one for signatures).
  • Method Details

    • builder

      public static JwtProvider.Builder builder()
      A builder for this provider.
      Returns:
      builder to create a new instance
    • create

      public static JwtProvider create(Config config)
      Create provider instance from configuration.
      Parameters:
      config - configuration of this provider
      Returns:
      provider instance
    • authenticate

      public AuthenticationResponse authenticate(ProviderRequest providerRequest)
      Description copied from interface: AuthenticationProvider
      Authenticate a request. This may be just resolving headers (tokens) or full authentication (basic auth). Do not throw exception for normal processing (e.g. invalid credentials; you may throw an exception in case of misconfiguration). This method will be invoked for inbound requests ONLY.

      This method must provide either a Principal or a whole Subject either for a user or for service (or both).

      Specified by:
      authenticate in interface AuthenticationProvider
      Parameters:
      providerRequest - context of this security enforcement/validation
      Returns:
      response that either authenticates the request, fails authentication or abstains from authentication
      See Also:
    • isOutboundSupported

      public boolean isOutboundSupported(ProviderRequest providerRequest, SecurityEnvironment outboundEnv, EndpointConfig outboundConfig)
      Description copied from interface: OutboundSecurityProvider
      Check if the path to be executed is supported by this security provider. Defaults to true.
      Specified by:
      isOutboundSupported in interface OutboundSecurityProvider
      Parameters:
      providerRequest - context with environment, subject(s) etc. that was received
      outboundEnv - environment for outbound call
      outboundConfig - outbound endpoint configuration
      Returns:
      true if this identity propagator can generate required headers for the path defined
    • outboundSecurity

      public OutboundSecurityResponse outboundSecurity(ProviderRequest providerRequest, SecurityEnvironment outboundEnv, EndpointConfig outboundEndpointConfig)
      Description copied from interface: OutboundSecurityProvider
      Creates necessary updates to headers and entity needed for outbound security (e.g. identity propagation, s2s security etc.). This method will be invoked for outbound requests ONLY.
      Specified by:
      outboundSecurity in interface OutboundSecurityProvider
      Parameters:
      providerRequest - context with environment, subject(s) etc. that was received
      outboundEnv - environment for outbound call
      outboundEndpointConfig - outbound endpoint configuration
      Returns:
      response with generated headers and other possible configuration
      See Also: