-
Notifications
You must be signed in to change notification settings - Fork 619
Skip claim config initialization for organizations #8101
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -28,6 +28,8 @@ | |||||||||||||||||||
| import org.wso2.carbon.identity.claim.metadata.mgt.util.ClaimConstants; | ||||||||||||||||||||
| import org.wso2.carbon.identity.claim.metadata.mgt.util.ClaimMetadataUtils; | ||||||||||||||||||||
| import org.wso2.carbon.identity.core.util.IdentityUtil; | ||||||||||||||||||||
| import org.wso2.carbon.identity.organization.management.service.exception.OrganizationManagementException; | ||||||||||||||||||||
| import org.wso2.carbon.identity.organization.management.service.util.OrganizationManagementUtil; | ||||||||||||||||||||
| import org.wso2.carbon.user.api.Claim; | ||||||||||||||||||||
| import org.wso2.carbon.user.api.ClaimMapping; | ||||||||||||||||||||
| import org.wso2.carbon.user.api.UserRealm; | ||||||||||||||||||||
|
|
@@ -60,6 +62,14 @@ public static DefaultClaimMetadataStore getInstance(int tenantId) { | |||||||||||||||||||
| public DefaultClaimMetadataStore(ClaimConfig claimConfig, int tenantId) { | ||||||||||||||||||||
|
|
||||||||||||||||||||
| try { | ||||||||||||||||||||
| /* | ||||||||||||||||||||
| * Child organization tenants do not maintain their own claim metadata. Therefore, the per-tenant | ||||||||||||||||||||
| * claim configuration initialization for the tenant must NOT run for child organization tenants. | ||||||||||||||||||||
| */ | ||||||||||||||||||||
| if (isOrganization(tenantId)) { | ||||||||||||||||||||
| this.tenantId = tenantId; | ||||||||||||||||||||
| return; | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
Comment on lines
+69
to
+72
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Log Improvement Suggestion No: 2
Suggested change
|
||||||||||||||||||||
| ReadWriteClaimMetadataManager dbBasedClaimMetadataManager = new DBBasedClaimMetadataManager(); | ||||||||||||||||||||
| if (!skipClaimMetadataPersistence() && dbBasedClaimMetadataManager.getClaimDialects(tenantId).isEmpty()) { | ||||||||||||||||||||
| IdentityClaimManagementServiceDataHolder.getInstance().getClaimConfigInitDAO() | ||||||||||||||||||||
|
|
@@ -68,10 +78,27 @@ public DefaultClaimMetadataStore(ClaimConfig claimConfig, int tenantId) { | |||||||||||||||||||
| } catch (ClaimMetadataException e) { | ||||||||||||||||||||
| log.error("Error while retrieving claim dialects", e); | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| this.tenantId = tenantId; | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| /** | ||||||||||||||||||||
| * Checks whether the given tenant corresponds to a child organization under a root organization. | ||||||||||||||||||||
| * | ||||||||||||||||||||
| * @param tenantId Tenant id to check. | ||||||||||||||||||||
| * @return {@code true} if the tenant is a child organization, {@code false} otherwise. | ||||||||||||||||||||
| */ | ||||||||||||||||||||
| private boolean isOrganization(int tenantId) { | ||||||||||||||||||||
|
|
||||||||||||||||||||
| try { | ||||||||||||||||||||
| return OrganizationManagementUtil.isOrganization(tenantId); | ||||||||||||||||||||
| } catch (OrganizationManagementException e) { | ||||||||||||||||||||
| log.error("Error while checking whether tenant: " + tenantId + | ||||||||||||||||||||
| " is a child organization during claim metadata store initialization. " + | ||||||||||||||||||||
| "Proceeding with the default claim configuration initialization path.", e); | ||||||||||||||||||||
|
Comment on lines
+95
to
+97
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ERROR log should not include the exception object. This As per coding guidelines, “for ERROR logs, log only the error message (no stack traces/exception objects).” 🤖 Prompt for AI Agents |
||||||||||||||||||||
| return false; | ||||||||||||||||||||
| } | ||||||||||||||||||||
|
Comment on lines
+94
to
+99
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fail-open fallback can initialize sub-organization tenants on org-check errors. When tenant-type detection fails, returning Suggested fix private boolean isOrganization(int tenantId) {
try {
return OrganizationManagementUtil.isOrganization(tenantId);
} catch (OrganizationManagementException e) {
- log.error("Error while checking whether tenant: " + tenantId +
- " is a sub-organization during claim metadata store initialization. " +
- "Proceeding with the default claim configuration initialization path.", e);
- return false;
+ log.error("Error while checking whether tenant: " + tenantId +
+ " is a sub-organization during claim metadata store initialization. " +
+ "Skipping claim configuration initialization for safety.");
+ return true;
}
}🤖 Prompt for AI Agents |
||||||||||||||||||||
| } | ||||||||||||||||||||
|
|
||||||||||||||||||||
| @Override | ||||||||||||||||||||
| public String[] getAllClaimUris() throws UserStoreException { | ||||||||||||||||||||
|
|
||||||||||||||||||||
|
|
||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Log Improvement Suggestion No: 1