mirror of
https://github.com/keycloak/keycloak.git
synced 2026-05-27 11:53:34 -04:00
add support for number and boolean claims in ClaimToUserSessionNoteMapper
Closes #45022
This commit is contained in:
parent
7be37f1e0d
commit
dfd0d9daf0
1 changed files with 16 additions and 14 deletions
|
|
@ -110,20 +110,9 @@ public class ClaimToUserSessionNoteMapper extends AbstractClaimMapper {
|
|||
Boolean.parseBoolean(mapperModel.getConfig().get(ARE_CLAIM_VALUES_REGEX_PROPERTY_NAME));
|
||||
|
||||
for (Map.Entry<String, List<String>> claim : claims.entrySet()) {
|
||||
Object claimValueObj = getClaimValue(context, claim.getKey());
|
||||
for (String value : claim.getValue()) {
|
||||
if (claimValueObj != null) {
|
||||
if (!(claimValueObj instanceof String)) {
|
||||
LOG.warnf(
|
||||
"Claim '%s' does not contain a string value for user with brokerUserId '%s'. "
|
||||
+ "Actual value is of type '%s': %s",
|
||||
claim.getKey(),
|
||||
context.getBrokerUserId(), claimValueObj.getClass(), claimValueObj);
|
||||
continue;
|
||||
}
|
||||
|
||||
String claimValue = (String) claimValueObj;
|
||||
|
||||
String claimValue = getStringCompatibleClaimValue(context, claim.getKey());
|
||||
if (claimValue != null) {
|
||||
for (String value : claim.getValue()) {
|
||||
boolean claimValuesMatch = areClaimValuesRegex ? valueMatchesRegex(value, claimValue)
|
||||
: valueEquals(value, claimValue);
|
||||
|
||||
|
|
@ -135,4 +124,17 @@ public class ClaimToUserSessionNoteMapper extends AbstractClaimMapper {
|
|||
}
|
||||
}
|
||||
|
||||
private String getStringCompatibleClaimValue(BrokeredIdentityContext context, String key) {
|
||||
Object claimValueObj = getClaimValue(context, key);
|
||||
if (claimValueObj instanceof String || claimValueObj instanceof Number || claimValueObj instanceof Boolean) {
|
||||
return claimValueObj.toString();
|
||||
}
|
||||
LOG.warnf(
|
||||
"Claim '%s' does not contain a string-compatible (String/Number/Boolean) value for user with brokerUserId '%s'. "
|
||||
+ "Actual value is of type '%s': %s",
|
||||
key,
|
||||
context.getBrokerUserId(), claimValueObj.getClass(), claimValueObj);
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue