Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix oidc claim mapping in jwt access token attributes #2655

Merged
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -264,12 +264,12 @@ private Map<String, Object> getOIDCClaimsFromUserAttributes(Map<ClaimMapping, St
/**
* Get oidc claims mapping.
*
* @param federatedUserAttributed User attributes.
* @param federatedUserAttributes User attributes.
* @param requestMsgCtx Request Context.
* @return User attributes Map.
*/
private Map<String, Object> getOIDCClaimsFromFederatedUserAttributes(Map<ClaimMapping,
String> federatedUserAttributed, OAuthTokenReqMessageContext requestMsgCtx)
String> federatedUserAttributes, OAuthTokenReqMessageContext requestMsgCtx)
throws IdentityOAuth2Exception {

String spTenantDomain = getServiceProviderTenantDomain(requestMsgCtx);
Expand All @@ -283,24 +283,16 @@ private Map<String, Object> getOIDCClaimsFromFederatedUserAttributes(Map<ClaimMa
}
// Get user claims in OIDC dialect.
Map<String, String> userClaimsInOidcDialect = new HashMap<>();
if (MapUtils.isNotEmpty(federatedUserAttributed)) {
for (Map.Entry<ClaimMapping, String> userAttribute : federatedUserAttributed.entrySet()) {
if (MapUtils.isNotEmpty(federatedUserAttributes)) {
for (Map.Entry<ClaimMapping, String> userAttribute : federatedUserAttributes.entrySet()) {
ClaimMapping claimMapping = userAttribute.getKey();
String claimValue = userAttribute.getValue();
if (oidcToLocalClaimMappings.containsValue(claimMapping.getLocalClaim().getClaimUri())) {
String localClaimURI = claimMapping.getLocalClaim().getClaimUri();
String oidcClaimUri = oidcToLocalClaimMappings.entrySet().stream()
.filter(entry -> entry.getValue().equals(localClaimURI))
.map(Map.Entry::getKey)
.findFirst()
.orElse(null);

if (oidcClaimUri != null) {
userClaimsInOidcDialect.put(oidcClaimUri, claimValue.toString());
if (log.isDebugEnabled() &&
IdentityUtil.isTokenLoggable(IdentityConstants.IdentityTokens.USER_CLAIMS)) {
log.debug("Mapped claim: key - " + oidcClaimUri + " value - " + claimValue);
}
String claimValue = userAttribute.getValue().toString();
String localClaimURI = claimMapping.getLocalClaim().getClaimUri();
if (oidcToLocalClaimMappings.containsKey(localClaimURI) && StringUtils.isNotBlank(claimValue)) {
userClaimsInOidcDialect.put(localClaimURI, claimValue);
if (log.isDebugEnabled() &&
IdentityUtil.isTokenLoggable(IdentityConstants.IdentityTokens.USER_CLAIMS)) {
log.debug("Mapped claim: key - " + localClaimURI + " value - " + claimValue);
}
}
}
Expand Down Expand Up @@ -638,17 +630,12 @@ private static Map<String, Object> getUserClaimsInOIDCDialectFromFederatedUserAt
for (Map.Entry<ClaimMapping, String> userAttribute : federatedUserAttr.entrySet()) {
ClaimMapping claimMapping = userAttribute.getKey();
String claimValue = userAttribute.getValue();
if (oidcToLocalClaimMappings.containsValue(claimMapping.getLocalClaim().getClaimUri())) {
String localClaimURI = claimMapping.getLocalClaim().getClaimUri();
String oidcClaimUri = oidcToLocalClaimMappings.entrySet().stream()
.filter(entry -> entry.getValue().equals(localClaimURI))
.map(Map.Entry::getKey).findFirst().orElse(null);
if (oidcClaimUri != null && StringUtils.isNotBlank(claimValue)) {
userClaimsInOidcDialect.put(oidcClaimUri, claimValue);
if (log.isDebugEnabled() &&
IdentityUtil.isTokenLoggable(IdentityConstants.IdentityTokens.USER_CLAIMS)) {
log.debug("Mapped claim: key - " + oidcClaimUri + " value - " + claimValue);
}
String localClaimURI = claimMapping.getLocalClaim().getClaimUri();
if (oidcToLocalClaimMappings.containsKey(localClaimURI) && StringUtils.isNotBlank(claimValue)) {
userClaimsInOidcDialect.put(localClaimURI, claimValue);
if (log.isDebugEnabled() &&
IdentityUtil.isTokenLoggable(IdentityConstants.IdentityTokens.USER_CLAIMS)) {
log.debug("Mapped claim: key - " + localClaimURI + " value - " + claimValue);
}
}
}
Expand Down
Loading