Importing Mapping Rule
JavaScript utilities that are defined in one JavaScript mapping rule can be imported into another mapping rule by using the feature importMappingRule.
Configuring rules.yaml
- Rule configuration
# Copyright contributors to the IBM Verify Identity Access OIDC Provider Resources project
version: 25.10
logging:
level: debug
rules:
mapping:
- name: pretoken
rule_type: javascript
content: '@rules/rule.js'
- name: logger
rule_type: javascript
content: '@rules/logger.js'
- name: hash
rule_type: javascript
content: '@rules/hash.js'
- logger JS mapping rule is defined to print debug logs.
importClass(Packages.com.tivoli.am.fim.trustserver.sts.utilities.IDMappingExtUtils);
function debugLog(String message){
IDMappingExtUtils.traceString("debugLogs :"+message);
}
- In the pretoken mapping rule, the following syntax is used to print debug logs.
importClass(Packages.com.tivoli.am.fim.trustserver.sts.utilities.IDMappingExtUtils);
importClass(Packages.com.tivoli.am.fim.trustserver.sts.utilities.OAuthMappingExtUtils);
importMappingRule("logger");
debugLog("Entering pre token mapping rule");
tokenData["custom1"] = "bcustom";
tokenData.custom2 = ["xcustom", "ycustom", "zcustom"]
idtokenData["custom1"] = "bcustom";
idtokenData["custom2"] = "bcustom";
debugLog("STSUU: " + stsuu.toString());
- importMappingRule should use the mapping rule name defined in the rule configuration.
- importMappingRule should use a literal rule name and not a variable.
Updated 1 day ago
