Hi Usman,
You can add additional attributes to the claims of the ID_TOKEN by adding them to the sts context in the pre-token mapping rule. The important thing to know is:
All Attributes with type
urn:ibm:jwt:claim will be added as claims
So, an example of adding upn would look like this:
var myupn = stsuu.getContextAttributes().getAttributeValueByName("upn_cred_attr")
stsuu.addContextAttribute(new com.tivoli.am.fim.trustserver.sts.uuser.Attribute("upn","urn:ibm:jwt:claim",myupn));This assumes UPN is in a credential attribute named "upn_cred_attr".
Note that credential attributes are only populated into the context when you hit the /authorize endpoint. This is fine for "implicit" flow (where ID_TOKEN is returned from /authorize) but doesn't work directly for "Authorization Code" flow (where ID_TOKEN is returned from /token).
If you're using the "Authorization Code" flow, you'll need to either set up an attribute source (so the attribute can be pulled from LDAP when needed) or store the attribute against the grant in the authorization code part of the flow and then retrieve it again in the token exchange part of the flow.
There's actually code already in the rules to do this work for attributes the client requests. I think you could directly add your attribute to this list at the start of processing and have the existing code handle it for you:
stsuu.setContextAttribute("cred_attr_upn", "urn:ibm:names:ITFIM:oidc:claim:voluntary",null);Jon.
------------------------------
Jon Harry
Consulting IT Security Specialist
IBM
------------------------------