Class IdcsMtRoleMapperProvider
java.lang.Object
io.helidon.security.providers.idcs.mapper.IdcsRoleMapperProviderBase
io.helidon.security.providers.idcs.mapper.IdcsMtRoleMapperProvider
- All Implemented Interfaces:
SecurityProvider, SubjectMappingProvider
SubjectMappingProvider to obtain roles from IDCS server for a user.
Supports multi tenancy in IDCS.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classFluent API builder forIdcsMtRoleMapperProvider.protected static classDefault implementation of theIdcsMtRoleMapperProvider.MultitenancyEndpoints.static classCache key for multitenant environments.static interfaceMultitenant endpoints for accessing IDCS services.Nested classes/interfaces inherited from class IdcsRoleMapperProviderBase
IdcsRoleMapperProviderBase.AppTokenModifier and TypeClassDescriptionprotected static classReactive token for app access to IDCS. -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final StringName of the header containing the IDCS app.protected static final StringName of the header containing the IDCS tenant.Fields inherited from class IdcsRoleMapperProviderBase
ACCESS_TOKEN_KEY, IDCS_SUBJECT_TYPE_CLIENT, IDCS_SUBJECT_TYPE_USER, PARENT_CONTEXT_CLIENT_PROPERTY, ROLE_APPROLE, ROLE_GROUPModifier and TypeFieldDescriptionprotected static final StringJson key for token to be retrieved from IDCS response when requesting application token.static final StringClient subject type used when requesting roles from IDCS.static final StringUser subject type used when requesting roles from IDCS.protected static final StringProperty sent with client requests to override parent span context in outbound calls.protected static final StringJson key for app roles to be retrieved from IDCS response.protected static final StringJson key for group roles to be retrieved from IDCS response. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedConfigure instance from any descendant ofIdcsMtRoleMapperProvider.Builder. -
Method Summary
Modifier and TypeMethodDescriptionaddAdditionalGrants(String idcsTenantId, String idcsAppName, Subject subject, List<Grant> idcsGrants) Extension point to add additional grants to the subject being created.builder()Creates a new builder to build instances of this class.computeGrants(String idcsTenantId, String idcsAppName, Subject subject) Compute grants for the provided MT information.static SecurityProviderCreates an instance from configuration.protected Subjectenhance(ProviderRequest request, AuthenticationResponse previousResponse, Subject subject) Enhance the subject with appropriate roles from IDCS.protected Optional<IdcsMtContext> extractIdcsMtContext(Subject subject, ProviderRequest request) Extract IDCS multitenancy context form the the request.getAppToken(String idcsTenantId, RoleMapTracing tracing) Gets token from cache or from server.getGrantsFromServer(String idcsTenantId, String idcsAppName, Subject subject) Get grants from IDCS server.Get theIdcsMtRoleMapperProvider.MultitenancyEndpointsused to get assertion and token endpoints of a multitenant IDCS.Methods inherited from class IdcsRoleMapperProviderBase
buildSubject, defaultIdcsSubjectType, map, oidcConfig, processRoleRequestModifier and TypeMethodDescriptionprotected SubjectbuildSubject(Subject originalSubject, List<? extends Grant> grants) Updates original subject with the list of grants.protected StringDefault subject type to use when requesting data from IDCS.map(ProviderRequest authenticatedRequest, AuthenticationResponse previousResponse) Map grants from authenticated request (e.g.protected OidcConfigAccess toOidcConfigso the field is not duplicated by classes that extend this provider.processRoleRequest(HttpClientRequest request, Object entity, String subjectName) Request roles from IDCS and process the response.Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface SecurityProvider
supportedAnnotations, supportedAttributes, supportedConfigKeys, supportedCustomObjectsModifier and TypeMethodDescriptiondefault Collection<Class<? extends Annotation>> Provide extension annotations supported by this provider (e.g.default Collection<String> A collection of attribute names expected by this provider to override endpoint configuration.default Collection<String> Keys expected in configuration.default Collection<Class<? extends ProviderConfig>> Class of the configuration type.
-
Field Details
-
IDCS_TENANT_HEADER
Name of the header containing the IDCS tenant. This is the default used, can be overridden in builder byIdcsMtRoleMapperProvider.Builder.idcsTenantTokenHandler(io.helidon.security.util.TokenHandler)- See Also:
-
IDCS_APP_HEADER
Name of the header containing the IDCS app. This is the default used, can be overriden in builder byIdcsMtRoleMapperProvider.Builder.idcsAppNameTokenHandler(io.helidon.security.util.TokenHandler)- See Also:
-
-
Constructor Details
-
IdcsMtRoleMapperProvider
Configure instance from any descendant ofIdcsMtRoleMapperProvider.Builder.- Parameters:
builder- containing the required configuration
-
-
Method Details
-
builder
Creates a new builder to build instances of this class.- Returns:
- a new fluent API builder.
-
create
Creates an instance from configuration.Expects:
- oidc-config to load an instance of
OidcConfig - cache-config (optional) to load an instance of
EvictableCachefor role caching
- Parameters:
config- configuration of this provider- Returns:
- a new instance configured from config
- oidc-config to load an instance of
-
enhance
protected Subject enhance(ProviderRequest request, AuthenticationResponse previousResponse, Subject subject) Enhance the subject with appropriate roles from IDCS.- Specified by:
enhancein classIdcsRoleMapperProviderBase- Parameters:
request- provider requestpreviousResponse- authenticated response (never null)subject- subject of the user (never null)- Returns:
- future with enhanced subject
-
computeGrants
-
extractIdcsMtContext
Extract IDCS multitenancy context form the the request.By default, the context is extracted from the headers using token handlers for
tenantandapp.- Parameters:
subject- Subject that is being mappedrequest- ProviderRequest context that is being mapped.- Returns:
- Optional with the context, empty if the context is not present in the request.
-
addAdditionalGrants
protected List<? extends Grant> addAdditionalGrants(String idcsTenantId, String idcsAppName, Subject subject, List<Grant> idcsGrants) Extension point to add additional grants to the subject being created.- Parameters:
idcsTenantId- IDCS tenant ididcsAppName- IDCS application namesubject- subject of the user/serviceidcsGrants- Roles already retrieved from IDCS- Returns:
- list with new grants to add to the enhanced subject
-
getGrantsFromServer
protected List<? extends Grant> getGrantsFromServer(String idcsTenantId, String idcsAppName, Subject subject) Get grants from IDCS server. The result is cached.- Parameters:
idcsTenantId- ID of the IDCS tenantidcsAppName- Name of IDCS applicationsubject- subject to get grants for- Returns:
- optional list of grants from server
-
getAppToken
Gets token from cache or from server.- Parameters:
idcsTenantId- id of tenanttracing- Role mapping tracing instance to correctly trace outbound calls- Returns:
- the token to be used to authenticate this service
-
multitenancyEndpoints
Get theIdcsMtRoleMapperProvider.MultitenancyEndpointsused to get assertion and token endpoints of a multitenant IDCS.- Returns:
- endpoints to use by this implementation
-