Class IssuedTokenClaims
java.lang.Object
com.irurueta.authserver.authorization.api.web.tokens.IssuedTokenClaims
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final StringName of the custom client setting that holds the audiences of the access tokens.private final List<JwtClaimsContributor> Contributors of additional claims, in order.private static final StringPrefix of the authorities that record how a user authenticated, such asFACTOR_PASSWORD.private final FindUserAccountUseCaseFinds the account of the user.(package private) static final org.springframework.security.oauth2.server.authorization.OAuth2TokenTypeType of the OpenID Connect ID token.static final StringName of the claim that holds the roles of the user.static final StringName of the claim that holds the tenant of the user. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidaddAccessTokenClaims(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.voidapply(org.springframework.security.oauth2.server.authorization.token.OAuth2TokenContext context, Map<String, Object> claims) Adds the claims of the token being issued.
-
Field Details
-
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
Name of the claim that holds the roles of the user.- See Also:
-
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_TOKENType of the OpenID Connect ID token. -
FACTOR_PREFIX
Prefix of the authorities that record how a user authenticated, such asFACTOR_PASSWORD.- See Also:
-
findUserAccountUseCase
Finds the account of the user. -
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.
-