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

Always use the PRIMARY userstore to add local claims in Asgardeo #440

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Changes from all commits
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 @@ -118,6 +118,8 @@ public class ServerClaimManagementService {
ClaimConstants.ErrorMessage.ERROR_CODE_EXISTING_EXTERNAL_CLAIM_URI.getCode(),
ClaimConstants.ErrorMessage.ERROR_CODE_EXISTING_LOCAL_CLAIM_URI.getCode()
);
private static final boolean RESTRICT_CLAIM_TO_PRIMARY_USERSTORE = Boolean.parseBoolean(IdentityUtil.getProperty(
sahandilshan marked this conversation as resolved.
Show resolved Hide resolved
"ClaimManagement.RestrictClaimsToPrimaryUserStore"));

/**
* Add a claim dialect.
Expand Down Expand Up @@ -969,6 +971,15 @@ private void validateAttributeMappings(List<AttributeMappingDTO> attributeMappin
throw handleClaimManagementClientError(ERROR_CODE_EMPTY_MAPPED_ATTRIBUTES_IN_LOCAL_CLAIM,
BAD_REQUEST, attributeMappingDTO.getUserstore());
}
if (RESTRICT_CLAIM_TO_PRIMARY_USERSTORE) {
// If the `ClaimManagement.RestrictClaimsToPrimaryUserStore` is enabled, we can only use the primary
// userstore for the claim mapping.
if (!primaryUserstoreDomainName.equalsIgnoreCase(attributeMappingDTO.getUserstore())) {
throw handleClaimManagementClientError(ERROR_CODE_INVALID_USERSTORE.getCode(), "You can only use"
Copy link
Contributor

@DMHP DMHP Apr 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need to throw this exception only if the host names are asgardeo.io and asg.io? We can't use any other userstore name even if we use a different domain right? (As the Asgardeo userstore is named as primary)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I needed to check whether this is on-prem or Asgardeo and if it's Asgardeo not allowed to use any other userstores. That's why I used this logic

+ " 'PRIMARY' userstore for the claim mapping.", BAD_REQUEST,
attributeMappingDTO.getUserstore());
}
}
if (!isUserStoreExists(attributeMappingDTO.getUserstore())) {
throw handleClaimManagementClientError(ERROR_CODE_INVALID_USERSTORE, BAD_REQUEST,
attributeMappingDTO.getUserstore());
Expand Down