Fix behaviour of return_only_mapped_local_roles property
@@ -298,9 +298,15 @@ public class DefaultStepBasedSequenceHandler implements StepBasedSequenceHandler
String idpRoleClaimUri = getIdpRoleClaimUri(stepConfig, context);
// Get the mapped user roles according to the mapping in the IDP configuration.
- // Include the unmapped roles as it is.
- List<String> identityProviderMappedUserRolesUnmappedInclusive = getIdentityProvideMappedUserRoles(
+ // If no mapping is provided, return all IDP roles as they are.
+ List<String> identityProviderMappedUserRolesUnmappedInclusive;
+ if (MapUtils.isEmpty(externalIdPConfig.getRoleMappings())) {
+ identityProviderMappedUserRolesUnmappedInclusive = getIdentityProvideMappedUserRoles(
+ externalIdPConfig, extAttibutesValueMap, idpRoleClaimUri, false);
+ } else {
+ identityProviderMappedUserRolesUnmappedInclusive = getIdentityProvideMappedUserRoles(
externalIdPConfig, extAttibutesValueMap, idpRoleClaimUri, returnOnlyMappedLocalRoles);
+ }
String serviceProviderMappedUserRoles = getServiceProviderMappedUserRoles(sequenceConfig,
identityProviderMappedUserRolesUnmappedInclusive);
@@ -309,6 +315,10 @@ public class DefaultStepBasedSequenceHandler implements StepBasedSequenceHandler
extAttibutesValueMap.put(idpRoleClaimUri, serviceProviderMappedUserRoles);
}
+ if (returnOnlyMappedLocalRoles && StringUtils.isBlank(serviceProviderMappedUserRoles)) {
+ extAttibutesValueMap.put(idpRoleClaimUri, serviceProviderMappedUserRoles);
+ }
+
if (mappedAttrs == null || mappedAttrs.isEmpty()) {
// do claim handling
mappedAttrs = handleClaimMappings(stepConfig, context,
