Class IssuedTokenClaims

java.lang.Object
com.irurueta.authserver.authorization.api.web.tokens.IssuedTokenClaims

@Component public class IssuedTokenClaims extends Object
The claims this server adds to the tokens it issues, whatever their format, so the self-contained (JWT) access tokens and the reference (opaque) ones carry the same claims: RolesTenantAudienceTokenCustomizer applies it to the JWTs and ReferenceTokenClaimsCustomizer to the claims stored for a reference token (which the introspection endpoint returns).

An access token gets roles, tenant and aud: the roles are the authorities of the user, the tenant comes from the user account, the audiences from the "settings.client.audiences" custom setting of the client. Tokens of the client credentials grant have no user, so they get no roles and no tenant. An ID token gets none of them. Then every JwtClaimsContributor, in order, adds its own claims to the access and ID tokens (it can tell them apart with OAuth2TokenContext.getTokenType()); no other token is touched.

  • Field Details

    • AUDIENCES_SETTING

      public static final String AUDIENCES_SETTING
      Name of the custom client setting that holds the audiences of the access tokens. It is the same name the persistence adapter writes (that module cannot be referenced from here).
      See Also:
    • ROLES_CLAIM

      public static final String ROLES_CLAIM
      Name of the claim that holds the roles of the user.
      See Also:
    • TENANT_CLAIM

      public static final String TENANT_CLAIM
      Name of the claim that holds the tenant of the user.
      See Also:
    • ID_TOKEN

      static final org.springframework.security.oauth2.server.authorization.OAuth2TokenType ID_TOKEN
      Type of the OpenID Connect ID token.
    • FACTOR_PREFIX

      private static final String FACTOR_PREFIX
      Prefix of the authorities that record how a user authenticated, such as FACTOR_PASSWORD.
      See Also:
    • findUserAccountUseCase

      private final FindUserAccountUseCase findUserAccountUseCase
      Finds the account of the user.
    • contributors

      private final List<JwtClaimsContributor> contributors
      Contributors of additional claims, in order.
  • Constructor Details

    • IssuedTokenClaims

      public IssuedTokenClaims()
  • Method Details

    • apply

      public void apply(org.springframework.security.oauth2.server.authorization.token.OAuth2TokenContext context, Map<String,Object> claims)
      Adds the claims of the token being issued.
      Parameters:
      context - the token context, with the token type, the principal, the client and the grant type.
      claims - the mutable claims of the token being built.
    • addAccessTokenClaims

      private void addAccessTokenClaims(org.springframework.security.oauth2.server.authorization.token.OAuth2TokenContext context, Map<String,Object> claims)
      Adds the roles, the tenant and the audiences of an access token.
      Parameters:
      context - the token context.
      claims - the mutable claims of the token being built.