Class UserRealmRoleMappingMapper
java.lang.Object
org.keycloak.protocol.oidc.mappers.AbstractOIDCProtocolMapper
org.keycloak.protocol.oidc.mappers.UserRealmRoleMappingMapper
- All Implemented Interfaces:
OIDCAccessTokenMapper,OIDCIDTokenMapper,TokenIntrospectionTokenMapper,UserInfoTokenMapper,ProtocolMapper,ConfiguredProvider,Provider,ProviderFactory<ProtocolMapper>
Allows mapping of user realm role mappings to an ID and Access Token claim.
- Author:
- Thomas Darimont
-
Field Summary
FieldsFields inherited from class org.keycloak.protocol.oidc.mappers.AbstractOIDCProtocolMapper
TOKEN_MAPPER_CATEGORY -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic ProtocolMapperModelcreate(String realmRolePrefix, String name, String tokenClaimName, boolean accessToken, boolean idToken, boolean introspectionEndpoint) static ProtocolMapperModelcreate(String realmRolePrefix, String name, String tokenClaimName, boolean accessToken, boolean idToken, boolean introspectionEndpoint, boolean multiValued) getId()intPriority of this protocolMapper implementation.protected static voidsetClaim(IDToken token, ProtocolMapperModel mappingModel, Set<String> rolesToAdd, String clientId, String prefix) Retrieves all roles of the current user based on direct roles set to the user, its groups and their parent groups.protected voidsetClaim(IDToken token, ProtocolMapperModel mappingModel, UserSessionModel userSession, KeycloakSession session, ClientSessionContext clientSessionCtx) Intended to be overridden inProtocolMapperimplementations to add claims to an token.Methods inherited from class org.keycloak.protocol.oidc.mappers.AbstractOIDCProtocolMapper
close, create, getEffectiveModel, getProtocol, getShouldUseLightweightToken, init, postInit, setClaim, setClaim, transformAccessToken, transformAccessTokenResponse, transformIDToken, transformIntrospectionToken, transformUserInfoTokenMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.keycloak.provider.ConfiguredProvider
getConfigMethods inherited from interface org.keycloak.protocol.oidc.mappers.OIDCAccessTokenMapper
transformAccessTokenMethods inherited from interface org.keycloak.protocol.oidc.mappers.OIDCIDTokenMapper
transformIDTokenMethods inherited from interface org.keycloak.protocol.ProtocolMapper
validateConfigMethods inherited from interface org.keycloak.provider.ProviderFactory
dependsOn, getConfigMetadata, orderMethods inherited from interface org.keycloak.protocol.oidc.mappers.TokenIntrospectionTokenMapper
transformIntrospectionTokenMethods inherited from interface org.keycloak.protocol.oidc.mappers.UserInfoTokenMapper
transformUserInfoToken
-
Field Details
-
PROVIDER_ID
- See Also:
-
-
Constructor Details
-
UserRealmRoleMappingMapper
public UserRealmRoleMappingMapper()
-
-
Method Details
-
getConfigProperties
-
getId
-
getDisplayType
-
getDisplayCategory
-
getHelpText
-
setClaim
protected void setClaim(IDToken token, ProtocolMapperModel mappingModel, UserSessionModel userSession, KeycloakSession session, ClientSessionContext clientSessionCtx) Description copied from class:AbstractOIDCProtocolMapperIntended to be overridden inProtocolMapperimplementations to add claims to an token.- Overrides:
setClaimin classAbstractOIDCProtocolMapper
-
create
public static ProtocolMapperModel create(String realmRolePrefix, String name, String tokenClaimName, boolean accessToken, boolean idToken, boolean introspectionEndpoint) -
create
public static ProtocolMapperModel create(String realmRolePrefix, String name, String tokenClaimName, boolean accessToken, boolean idToken, boolean introspectionEndpoint, boolean multiValued) -
getPriority
public int getPriority()Description copied from interface:ProtocolMapperPriority of this protocolMapper implementation. Lower goes first.- Specified by:
getPriorityin interfaceProtocolMapper- Returns:
-
setClaim
protected static void setClaim(IDToken token, ProtocolMapperModel mappingModel, Set<String> rolesToAdd, String clientId, String prefix) Retrieves all roles of the current user based on direct roles set to the user, its groups and their parent groups. Then it recursively expands all composite roles, and restricts according to the given predicaterestriction. If the current client sessions is restricted (i.e. no client found in active user session has full scope allowed), the final list of roles is also restricted by the client scope. Finally, the list is mapped to the token into a claim.- Parameters:
token-mappingModel-rolesToAdd-clientId-prefix-
-