How to convert email address to username?

Peter Schober peter.schober at univie.ac.at
Sat Feb 20 12:44:30 UTC 2021


* Mohamed Lrhazi <lrhazi at cua.edu> [2021-02-19 22:22]:
> Sometimes our users enter their email address at our IdP login
> page... How would one go about removing @doma.ain part before
> authentication and any attribute processing etc....

You could also simply authenticate on either the username *or* the
email adress making both work seamlessly, avoiding the need for any
transformations (whether in-browser or on the server).

Assuming you're using LDAP for authentication using one of the
(anon|bind)SearchAuthenticators, you'd put a slightly more complex
LDAP search filter with an OR condition in it into your
config/ldap.properties, e.g.:

  idp.authn.LDAP.userFilter = (|(uid={user})(mail={user}))

and again (for the resolver):

  idp.attribute.resolver.LDAP.searchFilter = (|(uid=$resolutionContext.principal)(mail=$resolutionContext.principal))

Adjust the LDAP attribute names for userid and email address as needed.

-peter


More information about the users mailing list