[Sync][master -> next][#3153]: Improve token validation for sub organization applications#3182
Open
github-actions[bot] wants to merge 2 commits intonextfrom
Open
[Sync][master -> next][#3153]: Improve token validation for sub organization applications#3182github-actions[bot] wants to merge 2 commits intonextfrom
github-actions[bot] wants to merge 2 commits intonextfrom
Conversation
Comment on lines
123
to
+124
| introspectionRequest.setRequiredClaimURIs(claimsUris); | ||
| introspectionRequest.setIntrospectionRequest(true); |
Contributor
There was a problem hiding this comment.
Log Improvement Suggestion No: 1
Suggested change
| introspectionRequest.setRequiredClaimURIs(claimsUris); | |
| introspectionRequest.setIntrospectionRequest(true); | |
| introspectionRequest.setRequiredClaimURIs(claimsUris); | |
| introspectionRequest.setIntrospectionRequest(true); | |
| log.info("Processing token introspection request"); |
Comment on lines
+1051
to
+1058
| private void validateIntrospectionForSubOrgTokens(String tenantDomain, AccessTokenDO accessTokenDO, | ||
| boolean isIntrospectionRequest) | ||
| throws OrganizationManagementException, IdentityOAuth2Exception, InvalidOAuthClientException { | ||
|
|
||
| String accessingOrgID = accessTokenDO.getAuthzUser().getAccessingOrganization(); | ||
| String orgIdOfIntrospectingTenant = OAuthComponentServiceHolder.getInstance().getOrganizationManager() | ||
| String introspectingTenantOrgId = OAuthComponentServiceHolder.getInstance().getOrganizationManager() | ||
| .resolveOrganizationId(tenantDomain); | ||
| boolean isValidToken = true; |
Contributor
There was a problem hiding this comment.
Log Improvement Suggestion No: 2
Suggested change
| private void validateIntrospectionForSubOrgTokens(String tenantDomain, AccessTokenDO accessTokenDO, | |
| boolean isIntrospectionRequest) | |
| throws OrganizationManagementException, IdentityOAuth2Exception, InvalidOAuthClientException { | |
| String accessingOrgID = accessTokenDO.getAuthzUser().getAccessingOrganization(); | |
| String orgIdOfIntrospectingTenant = OAuthComponentServiceHolder.getInstance().getOrganizationManager() | |
| String introspectingTenantOrgId = OAuthComponentServiceHolder.getInstance().getOrganizationManager() | |
| .resolveOrganizationId(tenantDomain); | |
| boolean isValidToken = true; | |
| private void validateIntrospectionForSubOrgTokens(String tenantDomain, AccessTokenDO accessTokenDO, | |
| boolean isIntrospectionRequest) | |
| throws OrganizationManagementException, IdentityOAuth2Exception, InvalidOAuthClientException { | |
| String accessingOrgID = accessTokenDO.getAuthzUser().getAccessingOrganization(); | |
| String introspectingTenantOrgId = OAuthComponentServiceHolder.getInstance().getOrganizationManager() | |
| .resolveOrganizationId(tenantDomain); | |
| log.debug("Validating introspection for sub-org tokens. Accessing Org: " + accessingOrgID + | |
| ", Introspecting Tenant Org: " + introspectingTenantOrgId); | |
| boolean isValidToken = true; |
Comment on lines
+1116
to
+1119
| } | ||
|
|
||
| if (!isValidToken) { | ||
| throw new IllegalArgumentException("Invalid Access Token. ACTIVE access token is not found."); |
Contributor
There was a problem hiding this comment.
Log Improvement Suggestion No: 3
Suggested change
| } | |
| if (!isValidToken) { | |
| throw new IllegalArgumentException("Invalid Access Token. ACTIVE access token is not found."); | |
| if (!isValidToken) { | |
| log.error("Token validation failed for accessing org: " + accessingOrgID + | |
| " and introspecting tenant org: " + introspectingTenantOrgId); | |
| throw new IllegalArgumentException("Invalid Access Token. ACTIVE access token is not found."); | |
| } |
Comment on lines
+602
to
+605
| @Test(dataProvider = "dataProviderForValidateIntrospectionForSubOrgTokens") | ||
| public void testValidateIntrospectionForSubOrgTokens(String accessingOrgID, String introspectingTenantOrgId, | ||
| String primaryOrgOfAccessingOrg, boolean isAppInSubOrg, boolean isFragmentApp, IssuerDetails issuerDetails, | ||
| boolean issuerIsOrg, String accessingOrgIdFromPath, boolean isIntrospectionRequest, boolean expectedValid) |
Contributor
There was a problem hiding this comment.
Log Improvement Suggestion No: 4
Suggested change
| @Test(dataProvider = "dataProviderForValidateIntrospectionForSubOrgTokens") | |
| public void testValidateIntrospectionForSubOrgTokens(String accessingOrgID, String introspectingTenantOrgId, | |
| String primaryOrgOfAccessingOrg, boolean isAppInSubOrg, boolean isFragmentApp, IssuerDetails issuerDetails, | |
| boolean issuerIsOrg, String accessingOrgIdFromPath, boolean isIntrospectionRequest, boolean expectedValid) | |
| public void testValidateIntrospectionForSubOrgTokens(String accessingOrgID, String introspectingTenantOrgId, | |
| String primaryOrgOfAccessingOrg, boolean isAppInSubOrg, boolean isFragmentApp, IssuerDetails issuerDetails, | |
| boolean issuerIsOrg, String accessingOrgIdFromPath, boolean isIntrospectionRequest, boolean expectedValid) | |
| throws Exception { | |
| if (log.isDebugEnabled()) { | |
| log.debug("Testing introspection validation for sub-org tokens with accessingOrgID: " + accessingOrgID + | |
| ", introspectingTenantOrgId: " + introspectingTenantOrgId + | |
| ", isAppInSubOrg: " + isAppInSubOrg); | |
| } |
Comment on lines
+706
to
+707
| validationRequest.setAccessToken(accessToken); | ||
| validationRequest.setIntrospectionRequest(isIntrospectionRequest); |
Contributor
There was a problem hiding this comment.
Log Improvement Suggestion No: 5
Suggested change
| validationRequest.setAccessToken(accessToken); | |
| validationRequest.setIntrospectionRequest(isIntrospectionRequest); | |
| OAuth2IntrospectionResponseDTO response = tokenValidationHandler | |
| .buildIntrospectionResponse(validationRequest); | |
| if (log.isDebugEnabled()) { | |
| log.debug("Introspection response received. Expected valid: " + expectedValid + | |
| ", Actual error: " + (response.getError() != null ? response.getError() : "none")); | |
| } |
Contributor
There was a problem hiding this comment.
AI Agent Log Improvement Checklist
- The log-related comments and suggestions in this review were generated by an AI tool to assist with identifying potential improvements. Purpose of reviewing the code for log improvements is to improve the troubleshooting capabilities of our products.
- Please make sure to manually review and validate all suggestions before applying any changes. Not every code suggestion would make sense or add value to our purpose. Therefore, you have the freedom to decide which of the suggestions are helpful.
✅ Before merging this pull request:
- Review all AI-generated comments for accuracy and relevance.
- Complete and verify the table below. We need your feedback to measure the accuracy of these suggestions and the value they add. If you are rejecting a certain code suggestion, please mention the reason briefly in the suggestion for us to capture it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🤖 Auto-sync from master
This PR automatically syncs the changes from #3153 to the
nextbranch.Original PR: #3153
Author: @ShanChathusanda93
Total commits: 2
Workflow run: https://github.com/wso2-extensions/identity-inbound-auth-oauth/actions/runs/24118391220
Commits: