Class PopulateDuoAuthenticationContext
- All Implemented Interfaces:
Component,DestructableComponent,InitializableComponent,ProfileAction,Aware,MessageSource,MessageSourceAware,Action
DuoOIDCAuthenticationContext
with the username, chosen DuoOIDCIntegration, and DuoOIDCClient appropriate for this request.
Operates in 2 modes, one for passwordless (indicated by presence of a DuoPasswordlessContext, or
a standard mode. The difference is in how the username and integration to use are derived.
Determines the usable redirect_uri, either from one registered, or computed from the HTTP request. Is set once, before the client is constructed, for every client. If however, the client supports dynamic use of the redirect_uri, it is also set into the context for use downstream.
Adds the nonce part of the state parameter for matching on callback from the 2FA check.
- Event:
EventIds.PROCEED_EVENT_ID,EventIds.INVALID_PROFILE_CTX,AuthnEventIds.NO_CREDENTIALS,AuthnEventIds.AUTHN_EXCEPTION- Postcondition:
- See above.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate DuoOIDCClientRegistryThe registry for locating the DuoClient for the established integration.private final org.slf4j.LoggerClass logger.Strategy used to locate aDuoPasswordlessContextif present.Lookup strategy for Duo integration for passwordless use.Strategy used to compute the redirectURI from the given Duo integration if supported.private StringParameter name for SSO bypass.Lookup strategy for Duo integration.private Function<ProfileRequestContext,String> Lookup strategy for username to match against Duo identity. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate voidcomputeAndStoreRedirectURIIfSupported(DuoOIDCIntegration duoIntegration, HttpServletRequest request, DuoOIDCAuthenticationContext context) ForDynamicDuoOIDCIntegrations, apply the redirect_uri creation strategy to compute a redirect_uri to use.protected voiddoExecute(ProfileRequestContext profileRequestContext, AuthenticationContext authenticationContext) protected voidprivate booleandoPasswordless(ProfileRequestContext profileRequestContext, AuthenticationContext authenticationContext, DuoOIDCAuthenticationContext duoContext, DuoPasswordlessContext passwordlessContext) Perform standard context creation and lookups.private booleandoStandard(ProfileRequestContext profileRequestContext, DuoOIDCAuthenticationContext duoContext) Perform standard context creation and lookups.voidsetClientRegistry(DuoOIDCClientRegistry duoRegistry) Set the Duo client registry.voidsetPasswordlessContextLookupStrategy(Function<ProfileRequestContext, DuoPasswordlessContext> strategy) Set the strategy used to locate theDuoPasswordlessContextto operate on.voidsetPasswordlessDuoIntegrationLookupStrategy(Function<ProfileRequestContext, DuoOIDCIntegration> strategy) Set passwordless DuoIntegration lookup strategy to use.voidsetRedirectURICreationStrategy(BiFunction<HttpServletRequest, DynamicDuoOIDCIntegration, String> strategy) Set the redirect URI creation strategy.voidsetSSOBypassFieldName(String fieldName) Set the SSO bypass parameter name.voidsetStandardDuoIntegrationLookupStrategy(Function<ProfileRequestContext, DuoOIDCIntegration> strategy) Set standard DuoIntegration lookup strategy to use.voidSet the lookup strategy to use for the username to match against Duo identity.Methods inherited from class net.shibboleth.idp.authn.AbstractAuthenticationAction
doExecute, doPreExecute, doPreExecute, setAuthenticationContextLookupStrategyMethods inherited from class net.shibboleth.idp.profile.AbstractProfileAction
doExecute, execute, getBean, getBean, getMessage, getMessage, getMessage, getParameter, getParameter, getProfileContextLookupStrategy, getRequestContext, getResult, setMessageSource, setProfileContextLookupStrategyMethods inherited from class org.opensaml.profile.action.AbstractConditionalProfileAction
getActivationCondition, setActivationConditionMethods inherited from class org.opensaml.profile.action.AbstractProfileAction
doPostExecute, doPostExecute, ensureHttpServletRequest, ensureHttpServletResponse, execute, getHttpServletRequest, getHttpServletRequestSupplier, getHttpServletResponse, getHttpServletResponseSupplier, getLogPrefix, isPreExecuteCalled, setHttpServletRequestSupplier, setHttpServletResponseSupplierMethods inherited from class net.shibboleth.shared.component.AbstractInitializableComponent
checkComponentActive, checkSetterPreconditions, destroy, doDestroy, ifDestroyedThrowDestroyedComponentException, ifInitializedThrowUnmodifiabledComponentException, ifNotInitializedThrowUninitializedComponentException, initialize, isDestroyed, isInitializedMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.shibboleth.shared.component.InitializableComponent
initialize, isInitialized
-
Field Details
-
log
@Nonnull private final org.slf4j.Logger logClass logger. -
passwordlessContextLookupStrategy
@Nonnull private Function<ProfileRequestContext,DuoPasswordlessContext> passwordlessContextLookupStrategyStrategy used to locate aDuoPasswordlessContextif present. -
usernameLookupStrategy
Lookup strategy for username to match against Duo identity. -
standardDuoIntegrationLookupStrategy
@Nonnull private Function<ProfileRequestContext,DuoOIDCIntegration> standardDuoIntegrationLookupStrategyLookup strategy for Duo integration. -
passwordlessDuoIntegrationLookupStrategy
@Nonnull private Function<ProfileRequestContext,DuoOIDCIntegration> passwordlessDuoIntegrationLookupStrategyLookup strategy for Duo integration for passwordless use. -
redirectURICreationStrategy
@Nullable private BiFunction<HttpServletRequest,DynamicDuoOIDCIntegration, redirectURICreationStrategyString> Strategy used to compute the redirectURI from the given Duo integration if supported. -
ssoBypassFieldName
Parameter name for SSO bypass. -
clientRegistry
The registry for locating the DuoClient for the established integration.
-
-
Constructor Details
-
PopulateDuoAuthenticationContext
public PopulateDuoAuthenticationContext()Constructor.
-
-
Method Details
-
setClientRegistry
Set the Duo client registry.- Parameters:
duoRegistry- the registry
-
setUsernameLookupStrategy
Set the lookup strategy to use for the username to match against Duo identity.- Parameters:
strategy- lookup strategy
-
setRedirectURICreationStrategy
public void setRedirectURICreationStrategy(@Nonnull BiFunction<HttpServletRequest, DynamicDuoOIDCIntegration, String> strategy) Set the redirect URI creation strategy. The strategy is free to use or create a redirectURI based either on runtime parameters, or static information in theDuoOIDCIntegration.- Parameters:
strategy- the creation strategy.
-
setPasswordlessContextLookupStrategy
public void setPasswordlessContextLookupStrategy(@Nonnull Function<ProfileRequestContext, DuoPasswordlessContext> strategy) Set the strategy used to locate theDuoPasswordlessContextto operate on.- Parameters:
strategy- lookup strategy- Since:
- 2.1.0
-
setStandardDuoIntegrationLookupStrategy
public void setStandardDuoIntegrationLookupStrategy(@Nonnull Function<ProfileRequestContext, DuoOIDCIntegration> strategy) Set standard DuoIntegration lookup strategy to use.- Parameters:
strategy- lookup strategy
-
setPasswordlessDuoIntegrationLookupStrategy
public void setPasswordlessDuoIntegrationLookupStrategy(@Nonnull Function<ProfileRequestContext, DuoOIDCIntegration> strategy) Set passwordless DuoIntegration lookup strategy to use.- Parameters:
strategy- lookup strategy- Since:
- 2.1.0
-
setSSOBypassFieldName
Set the SSO bypass parameter name.- Parameters:
fieldName- the SSO bypass parameter name- Since:
- 2.1.0
-
doInitialize
- Overrides:
doInitializein classAbstractInitializableComponent- Throws:
ComponentInitializationException
-
doExecute
protected void doExecute(@Nonnull ProfileRequestContext profileRequestContext, @Nonnull AuthenticationContext authenticationContext) - Overrides:
doExecutein classAbstractAuthenticationAction
-
doPasswordless
private boolean doPasswordless(@Nonnull ProfileRequestContext profileRequestContext, @Nonnull AuthenticationContext authenticationContext, @Nonnull DuoOIDCAuthenticationContext duoContext, @Nonnull DuoPasswordlessContext passwordlessContext) Perform standard context creation and lookups.- Parameters:
profileRequestContext- profile request contextauthenticationContext- authentication contextduoContext- newly created Duo contextpasswordlessContext- Duo passwordless context- Returns:
- true iff processing should continue
-
doStandard
private boolean doStandard(@Nonnull ProfileRequestContext profileRequestContext, @Nonnull DuoOIDCAuthenticationContext duoContext) Perform standard context creation and lookups.- Parameters:
profileRequestContext- profile request contextduoContext- newly created Duo context- Returns:
- true iff processing should continue
-
computeAndStoreRedirectURIIfSupported
private void computeAndStoreRedirectURIIfSupported(@Nonnull DuoOIDCIntegration duoIntegration, @Nonnull HttpServletRequest request, @Nonnull DuoOIDCAuthenticationContext context) throws DuoException ForDynamicDuoOIDCIntegrations, apply the redirect_uri creation strategy to compute a redirect_uri to use.The redirect_uri is computed for each request, but is only set once as the usable redirect_uri on the integration itself i.e. for the client to read using
DuoOIDCIntegration.getRedirectURI(). This allows all clients to see a computed (by theredirectURICreationStrategy) redirect_uri from the first request onward.The computed redirect_uri is also added to the context as an override redirect_uri which - if supported by the client - can be used dynamically when creating authorization or token exchange requests.
- Parameters:
duoIntegration- the Duo integration pertaining to this request.request- the http servlet request.context- the Duo authentication context to store the computed override redirect_uri.- Throws:
DuoException- if the redirect_uri could not be created by the strategy.
-