Cas - configure Principal transformation

802 Views Asked by At

I need to transform principal before get attributes. I'm using CAS 6.1 and the class that creates the Principal is: PersonDirectoryPrincipalResolver (https://github.com/apereo/cas/blob/6.1.x/core/cas-server-core-authentication-api/src/main/java/org/apereo/cas/authentication/principal/resolvers/PersonDirectoryPrincipalResolver.java).

How can I transform the principal? There is a "principalNameTransformer" attribute but I don't know how to configure it.

1

There are 1 best solutions below

2
On

Per CAS documentation,

Authentication handlers that generally deal with username-password credentials can be configured to transform the user id prior to executing the authentication sequence. Each authentication strategy in CAS provides settings to properly transform the principal.

This means for a given authentication handler/scheme, you can find a reference in the properties guide such as:

Principal transformation settings for this feature [meaning authentication handler] are under the configuration key cas.authn.file.

...and available properties are here:

# ${configurationKey}.principalTransformation.pattern=(.+)@example.org
# ${configurationKey}.principalTransformation.groovy.location=file:///etc/cas/config/principal.groovy
# ${configurationKey}.principalTransformation.suffix=
# ${configurationKey}.principalTransformation.caseConversion=NONE|UPPERCASE|LOWERCASE
# ${configurationKey}.principalTransformation.prefix=

Enable and tweak the ones you want.

To understand what a configuration key is, see this.