1

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.

gascani
  • 41
  • 1
  • 8

1 Answers1

1

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.

Misagh Moayyed
  • 4,154
  • 2
  • 15
  • 25
  • Thank you for the answer but I don't need to transform the principal before the authentication but after. My use case is that user enter his credential: es: johndoe@domain.com and after ldap authentication I want to retrieve attributes using only the username: johndoe. To retrieve attributes I'm using "cas.authn.attributeRepository.jdbc" that doesn't support principalTransformation. – gascani Jul 24 '20 at 06:57
  • For this reason I was trying a way to transform the principalId into PersonDirectoryPrincipalResolver through principalNameTransformer but I don't know if it's the right way – gascani Jul 24 '20 at 07:16