Fix consent page for mandatory attributes #2685
Merged
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.
Proposed changes in this pull request
Issue: wso2/product-is#21888
We have two claim categories: Required and Mandatory. These claims can be configured in the User Attributes section. Before filtering the claims for pre-consent, the claims are returned by the framework. The requested scopes are then filtered, and the consent page is displayed.
Over time, we implemented several fixes that inadvertently disrupted this flow.
In PR #1698, we introduced a change to pass the requested scopes first to the framework. The framework would then filter the claims and return both Required and Mandatory claims. However, this approach had a flaw where essential claims were missed.
To address this, in PR #2405, we reverted the behavior to stop passing scopes to the framework, restoring the previous logic while filtering essential claims. Unfortunately, this introduced another issue.
As mentioned in Issue #21888, even if the requested scopes do not include mandatory attributes, these attributes still appear on the consent page. This happens because filtering was removed. Although this is an edge case (e.g., why would an attribute be configured as mandatory but not requested by the client?), it still needs to be addressed to ensure consent is only provided for requested attributes.
This PR resolves the issue, ensuring that the consent page reflects only the requested scopes and associated attributes, maintaining expected behavior.
I tested all three issues to avoid any regressions.
Consent should be given only requested attributes.
1.mp4
claims
parameter in theoauth2/authorize
call wso2/product-is#19817Essential claims request and response should work as expected with proper consent screen
2.mp4
3.mp4