Class ClientPermissionsAccessTokenEnhancer
java.lang.Object
com.broadleafcommerce.auth.user.session.token.enhancer.ClientPermissionsAccessTokenEnhancer
- All Implemented Interfaces:
JwtAccessTokenEnhancer,org.springframework.core.Ordered
This
JwtAccessTokenEnhancer determines the set of all permissions available to a
client-only principal specified in the given JwtTokenEnhancerContext. This set of
permissions is added to JwtTokenEnhancerContext.getAdditionalContext(). Note, this
enhancer does not actually add any claims to the token context.- Author:
- Cade Rea (cade-rea), Samarth Dhruva (samarthd)
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class -
Field Summary
FieldsFields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE -
Constructor Summary
ConstructorsConstructorDescriptionClientPermissionsAccessTokenEnhancer(PrivilegeService privilegeService, TokenEnhancerUtility tokenEnhancerUtility, TokenProperties tokenProperties, AuthorizedClientService<AuthorizedClient> authorizedClientService) -
Method Summary
Modifier and TypeMethodDescriptionvoidenhance(JwtTokenEnhancerContext context) Evaluate the authentication and add claims as necessary.expandPermissionsWithAllPrefix(Collection<String> nonExpandedPermissions) This method expands any permission prefixed byPermissionType.ALLinto variousPermissionTypesuch asPermissionType.READorPermissionType.CREATE.protected AuthorizedClientService<AuthorizedClient>intgetOrder()protected PrivilegeServiceprotected TokenEnhancerUtilityprotected TokenPropertiesprotected booleanprotected Optional<AuthorizedClient>readMatchingAuthorizedClient(org.springframework.security.oauth2.server.authorization.client.RegisteredClient registeredClient) Read theAuthorizedClientfor the givenRegisteredClientby client_id.
-
Field Details
-
CLIENT_AUTHORITIES
- See Also:
-
-
Constructor Details
-
ClientPermissionsAccessTokenEnhancer
public ClientPermissionsAccessTokenEnhancer(PrivilegeService privilegeService, TokenEnhancerUtility tokenEnhancerUtility, TokenProperties tokenProperties, AuthorizedClientService<AuthorizedClient> authorizedClientService)
-
-
Method Details
-
enhance
Description copied from interface:JwtAccessTokenEnhancerEvaluate the authentication and add claims as necessary. AJwtTokenEnhancerContextcontains User and client authentication tokens, authorization tokens, and access token claims.- Specified by:
enhancein interfaceJwtAccessTokenEnhancer- Parameters:
context- TheJwtTokenEnhancerContextto evaluate.
-
readMatchingAuthorizedClient
protected Optional<AuthorizedClient> readMatchingAuthorizedClient(@Nullable org.springframework.security.oauth2.server.authorization.client.RegisteredClient registeredClient) Read theAuthorizedClientfor the givenRegisteredClientby client_id.- Parameters:
registeredClient- TheRegisteredClientwhoseAuthorizedClientshould be retrieved.- Returns:
- Optional with the
AuthorizedClientthat corresponds to the givenRegisteredClient.
-
expandPermissionsWithAllPrefix
This method expands any permission prefixed byPermissionType.ALLinto variousPermissionTypesuch asPermissionType.READorPermissionType.CREATE. The full set can be found inPermissionUtils.expandAllPermission(String).Whether expansion is actually performed is gated on
isExplodePermissions().- Parameters:
nonExpandedPermissions- the initial set of permissions, potentially containing non-expandedPermissionType.ALLpermissions- Returns:
- the input permissions (including any original
PermissionType.ALL-prefixed permissions), with additional permissions coming from expandedPermissionType.ALLvalues as applicable
-
isExplodePermissions
protected boolean isExplodePermissions() -
getOrder
public int getOrder()- Specified by:
getOrderin interfaceJwtAccessTokenEnhancer- Specified by:
getOrderin interfaceorg.springframework.core.Ordered
-
getPrivilegeService
-
getTokenEnhancerUtility
-
getTokenProperties
-
getAuthorizedClientService
-