Hi Piyush,
I think the issue here is the type that you are setting in the Attribute creation. When you use:
"urn:ibm:security:asf:response:token:attributes"
as the type, the value is assumed to have multiple values and must be provided as a string array.
When you use:
"urn:ibm:security:asf:response:token:attribute"
as the type, the value is assumed to have a single value and must be provided as a string.
So, this:
stsuu.addAttribute(
new Attribute(
"AZN_CRED_AUTHNMECH_INFO",
"urn:ibm:security:asf:response:token:attributes",
"Fake"));
will fail. Change to either:
stsuu.addAttribute(
new Attribute(
"AZN_CRED_AUTHNMECH_INFO",
"urn:ibm:security:asf:response:token:attribute",
"Fake"));
or
stsuu.addAttribute(
new Attribute(
"AZN_CRED_AUTHNMECH_INFO",
"urn:ibm:security:asf:response:token:attributes", [
"Fake"]));
This applies to all the sts.addAttribute calls you're making in your script.
Jon.
------------------------------
Jon Harry
Consulting IT Security Specialist
IBM
------------------------------
Original Message:
Sent: Fri March 05, 2021 05:36 PM
From: Piyush Agrawal
Subject: EAI Headers with Infomap and OIDC Mapping rule
Hello Jon,
Thank you for reply.
Yes you are right I am modiying OIDC RP definition oidc_rp.js which looks like following, but still doesn't work, I can see groups, Authentication_level in credentials and redirect url is also working but attribute "AZN_*" doesn't populate
var sub = stsuu.getAttributeContainer().getAttributeValueByName("sub");
stsuu.setPrincipalName(sub.toUpperCase());
var finalAttrs = [];
for (var i = 0; i < token_attribute_names.length; i++) {
var attr = stsuu.getAttributeContainer().getAttributeByName(token_attribute_names[i]);
if (attr != null) {
attr.setName(tokenToSTSCredMappingAttribute(token_attribute_names[i]))
finalAttrs.push(attr);
}
}
stsuu.clearAttributeList();
stsuu.addGroup(new Group("My_Overview", "urn:ibm:security:asf:response:token:attributes", null));
stsuu.addAttribute(new Attribute("AUTHENTICATION_LEVEL", "urn:ibm:security:asf:response:token:attributes", "3"));
stsuu.addAttribute(new Attribute("AZN_CRED_AUTHNMECH_INFO", "urn:ibm:security:asf:response:token:attributes", "Fake"));
stsuu.addAttribute(new Attribute("AZN_CRED_USER_INFO", "urn:ibm:security:asf:response:token:attributes", "1614980740"));
if (targetUrl != null && targetUrl.length() > 0) {
var targetUrlAttr = new Attribute("itfim_override_targeturl_attr", "urn:ibm:security:asf:response:token:attributes", targetUrl);
stsuu.addAttribute(targetUrlAttr);
}
When I am trying to work on Infomap as you suggested, I am getting ClassCastException
96 Caused by: org.mozilla.javascript.WrappedException: Wrapped java.lang.ClassCastException: java.lang.String incompatible with [Ljava.lang.String; (InfoMap_RememberMeUsername#73)
97 at org.mozilla.javascript.Context.throwAsScriptRuntimeEx(Context.java:1932)
98 at org.mozilla.javascript.MemberBox.invoke(MemberBox.java:148)
99 at org.mozilla.javascript.NativeJavaMethod.call(NativeJavaMethod.java:225)
100 at org.mozilla.javascript.optimizer.OptRuntime.callN(OptRuntime.java:52)
101 at org.mozilla.javascript.gen.InfoMap_RememberMeUsername_628._c_script_0(InfoMap_RememberMeUsername:73)
102 at org.mozilla.javascript.gen.InfoMap_RememberMeUsername_628.call(InfoMap_RememberMeUsername)
103 at org.mozilla.javascript.ContextFactory.doTopCall(ContextFactory.java:405)
104 at org.mozilla.javascript.ScriptRuntime.doTopCall(ScriptRuntime.java:3508)
105 at org.mozilla.javascript.gen.InfoMap_RememberMeUsername_628.call(InfoMap_RememberMeUsername)
106 at org.mozilla.javascript.gen.InfoMap_RememberMeUsername_628.exec(InfoMap_RememberMeUsername)
107 at com.ibm.security.access.javascript.JSCode.execute(JSCode.java:123)
Regards,
Piyush
------------------------------
Piyush Agrawal
------------------------------
Original Message:
Sent: Wed March 03, 2021 06:29 AM
From: Jon Harry
Subject: EAI Headers with Infomap and OIDC Mapping rule
Hi Piyush,
The OIDC "Advanced Configuration Mapping Rule" is specific to the OIDC Relying Party in federation add-on and is used to modify requests being sent to the OIDC Provider. I don't see any use case for adding sending EAI-type headers in these requests. If I remember correctly, it isn't possible to manipulate HTTP headers in these requests (although I know others would like to be able to do this and I think there is an RFE open).
If you're trying to get EAI headers returned from OIDC RP functionality, you would need to do this by setting STS attributes in the mapping rule of the OIDC RP definition. In that mapping rule you would use this code to add an attribute:
var myAttr = new Attribute("AZN_CRED_AUTHNMECH_INFO","urn:ibm:names:ITFIM:5.1:accessmanager", "Fake");stsuu.addAttribute(myAttr);
When you're working with an InfoMap (for a custom AAC Authentication mechanism), an attribute is added to set to be returned via EAI (to appear in users credential after successful authentication completion) using the following code:
context.set(Scope.SESSION,"urn:ibm:security:asf:response:token:attribute", "AZN_CRED_AUTHNMECH_INFO","Fake");
I hope this helps.
Jon.
------------------------------
Jon Harry
Consulting IT Security Specialist
IBM