Azure deleted authentication and mapping attributes

51 views
Skip to first unread message

Pablo Vidaurri

unread,
Jan 31, 2024, 11:49:51 PM1/31/24
to CAS Community
I'm about to authenticate against azure, and process the token for user attrubutes. I am also able to remap attributes via service config:
{
                    "@class": "org.apereo.cas.services.ReturnMappedAttributeReleasePolicy",
                    "allowedAttributes": {
                        "@class": "java.util.TreeMap",
                        "upn": "Email",
                        "givenName": "firstName",
                        "surName": "lastName"
                    }
                }

But I need the mapped attributes during my login webflow action. The mapped attribute does not exist at this point until after the service ticket is created I assume.

Remapping via
cas.authn.pac4j.oidc[0].azure.mapped-claims=upn->Email
does not appear to be fully implemented in v6.6.8. 

Is there anyway to map this or should I resort to modifying principal attributes during my login webflow?

-psv

Pablo Vidaurri

unread,
Feb 1, 2024, 12:19:37 AM2/1/24
to CAS Community, Pablo Vidaurri
Sorry, title should have been "delegated", not "deleted".

I already had a custom web flow setup, so I just remapped the attributes and added them back into the principal attributes:

val authentication = WebUtils.getAuthentication(context);
Principal principle = authentication.getPrincipal();
Map<String, List<Object>> attributesMap = principle.getAttributes();

remapAttribute(attributesMap, "Email", "upn");

private void remapAttribute(Map<String, List<Object>> attributesMap, String keyToAdd, String keyToCopy) {
if(!attributesMap.containsKey(keyToAdd) && attributesMap.containsKey(keyToCopy)) {
attributesMap.put(keyToAdd, Arrays.asList(attributesMap.get(keyToCopy).get(0)));
}
}
Reply all
Reply to author
Forward
0 new messages