AttributePostLoginC14NConfiguration

Current File(s):conf/c14n/attribute-sourced-subject-c14n-config.xml (V4.0), conf/c14n/subject-c14n.properties (V4.1+)
Format: Native Spring, Properties (V4.1+)

Overview

The c14n/attribute post-login subject canonicalization flow extracts a username from an IdPAttribute resolved (primarily) using the attribute resolution function within the IdP. A common use for this flow is to perform a directory or database lookup to map information derived from the authentication process (e.g. the subject of a certificate) into a different value for use within the IdP.

A secondary feature in V4.1+ allows for a Subject that contains one or more IdPAttributePrincipal objects to be processed directly for an IdPAttribute to pull the value from. This is primarily of use with various "external" authentication options such as SAML proxying, allowing a SAML Attribute decoded from another IdP to be directly consumed and used as a canonical principal name without the hassle of the attribute resolution process (and configuration).

General Configuration

Using the Attribute Resolver

When relying on the Attribute Resolver with this feature, there are additional considerations of which to be aware.

Usually, the attribute resolver relies on the canonical principal name to do its work (the value of the $resolutionContext.principal variable in scripts or search templates). By definition that isn't possible here (this is the process that provides that value later), but the value of that variable in the resolver can be set by means of a function bean (e.g., using a script) named shibboleth.c14n.attribute.PrincipalNameLookupStrategy. In most cases this function would peek inside the Java Subject being canonicalized and pull out custom bits of information.

The Java Subject this flow is operating on can be accessed via an expression of the form:

1 profileContext.getSubcontext("net.shibboleth.idp.authn.context.SubjectCanonicalizationContext").getSubject()

While it would not be a typical case to need to access a value entered by a user except in one specific case noted below, that value will be present inside the Subject as a principal object of type net.shibboleth.idp.authn.principal.UsernamePrincipal. In most other cases, it's simpler to just leave such a value as the canonical principal name and adjust your resolver configuration to accomodate whatever that might be than to try and use the resolver ahead of time to turn it into some other value.

Examples

MFA Example

One situation where this feature is frequently useful:

  • you need to use a Duo or other 2FA authentication plugin that would rely on the username entered by the user to send to the 2FA service

  • you want to allow the user to enter their username as one of several different identifiers when they do the initial password authentication

In that case, the same user could end up having multiple different identifiers with the 2FA service, because whichever one they choose to enter at login would be the one sent. This can be solved by using this attribute-based canonicalization, so that you ensure the same user identifier is sent to the 2FA service every time.

The following example illustrates how one could do this, where one has chosen to allow the user to enter either their uid or their e-mail address as the username. Changes need to be made to all of the following, and sample config highlights the changes to each that would enable such. (One would also need to configure your authn handler to allow for either input, such as changing idp.authn.LDAP.userFilter to '(|(uid={user})(mail={user}))'.)

  • conf/attribute-resolver.xml

  • conf/c14n/subject-c14n.xml

  • conf/c14n/attribute-sourced-subject-c14n-config.xml (V4.0) or conf/c14n/subject-c14n.properties (V4.1+)

The example takes the user's input name and supplies it to the attribute resolver to do a search of LDAP against the two possible candidate attributes and returns the uid attribute from the directory so that either input maps to a fixed output. There are other ways to configure the resolver that might be more aligned to other searches you need to perform, cache results, etc. but this illustrates the idea.

attribute-resolver.xml
1 2 3 4 5 6 7 8 9 10 11 12 13     <!-- Example LDAP Connector -->     <resolver:DataConnector id="myLDAP" xsi:type="dc:LDAPDirectory" exportAttributes="uid"        ldapURL="ldap://localhost:10389"        baseDN="ou=People,dc=example,dc=edu"        principal="cn=admin,dc=example,dc=edu"        principalCredential="password">        <dc:FilterTemplate>            <![CDATA[                (|(uid=$resolutionContext.principal)(mail=$resolutionContext.principal))            ]]>        </dc:FilterTemplate>        <dc:ReturnAttributes>uid</dc:ReturnAttributes>     </resolver:DataConnector>
subject-c14n.xml
1 2 <!-- Remove comment tags to enable Attribute-based c14n --> <bean id="c14n/attribute" parent="shibboleth.PostLoginSubjectCanonicalizationFlow" />

Reference