Add relation, timestamp filter and attributes to /me consents; allow authorizer access - #307
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughSummary
WalkthroughThe consent API now supports Sequence Diagram(s)sequenceDiagram
participant Client
participant MeApiServiceImpl
participant UserConsentService
participant ConsentManager
Client->>MeApiServiceImpl: Request consents with relation and attributes
MeApiServiceImpl->>UserConsentService: Forward consent list parameters
UserConsentService->>ConsentManager: List receipts for the authenticated user
ConsentManager-->>UserConsentService: Return matching receipts
UserConsentService-->>MeApiServiceImpl: Return populated consent summaries
MeApiServiceImpl-->>Client: Return consent list response
Suggested reviewers: Merge Risk: ⚪ Minimal · up to The PR expands consent listing and authorizer access with documented filtering and optional response attributes; no actionable merge-blocking risk remains based on the supplied evidence. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR extends the User Consent “me” API to support listing and retrieving consents beyond only the authenticated subject, and to optionally enrich list responses with additional consent details.
Changes:
- Adds
relation(SUBJECT/AUTHORIZER/ANY) andattributesquery parameters to the list consents endpoint, and updates the OpenAPI contract accordingly. - Expands list response payload (
ConsentSummary) withsubjectIdand optionalpurposes,authorizations, andproperties(populated on-demand viaattributes). - Updates consent access behavior/documentation to allow “involved users” (subject or authorized users) to retrieve/revoke/validate consent records, and adds timestamp filtering support.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| components/org.wso2.carbon.identity.api.user.consent/org.wso2.carbon.identity.api.user.consent.v1/src/main/resources/consent.yaml | Updates OpenAPI: new query params (relation, attributes), timestamp filter docs, richer ConsentSummary, and 400 response for list. |
| components/org.wso2.carbon.identity.api.user.consent/org.wso2.carbon.identity.api.user.consent.v1/src/main/java/org/wso2/carbon/identity/api/user/consent/v1/impl/MeApiServiceImpl.java | Wires new query params through the REST implementation to the core service. |
| components/org.wso2.carbon.identity.api.user.consent/org.wso2.carbon.identity.api.user.consent.v1/src/main/java/org/wso2/carbon/identity/api/user/consent/v1/impl/core/UserConsentService.java | Implements relation/attribute handling, timestamp filter validation, involved-user access, and optional attribute population for list responses. |
| components/org.wso2.carbon.identity.api.user.consent/org.wso2.carbon.identity.api.user.consent.v1/src/gen/java/org/wso2/carbon/identity/api/user/consent/v1/model/ConsentSummary.java | Updates generated model to include new fields returned by list responses. |
| components/org.wso2.carbon.identity.api.user.consent/org.wso2.carbon.identity.api.user.consent.v1/src/gen/java/org/wso2/carbon/identity/api/user/consent/v1/model/ConsentPurposeSummary.java | Adds new generated model used when attributes includes purposes. |
| components/org.wso2.carbon.identity.api.user.consent/org.wso2.carbon.identity.api.user.consent.v1/src/gen/java/org/wso2/carbon/identity/api/user/consent/v1/MeApiService.java | Updates generated service interface signature for list endpoint. |
| components/org.wso2.carbon.identity.api.user.consent/org.wso2.carbon.identity.api.user.consent.v1/src/gen/java/org/wso2/carbon/identity/api/user/consent/v1/MeApi.java | Updates generated JAX-RS resource for new query params and updated endpoint notes/responses. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
|
PR builder started |
|
PR builder completed |
|
PR builder started |
|
PR builder completed |
jenkins-is-staging
left a comment
There was a problem hiding this comment.
Approving the pull request based on the successful pr build https://github.com/wso2/product-is/actions/runs/32812216503
Purpose
Brings the consent delegation model to the self-service API: a user can now list consents they authorize as well as those they gave, filter by creation time, expand list responses selectively, and read, validate and revoke a consent they are a listed authorizer of.
Related Issue: wso2/product-is#28322
Merge After: wso2/carbon-consent-management#285
API changes
GET /me/consentsrelationSUBJECT(default) |AUTHORIZER|ANY.attributespurposes,authorizations,properties.filtertimestampwithge/le(milliseconds since epoch).ConsentSummarygainssubjectId, plus optionalpurposes,authorizationsandpropertiespopulated only when requested viaattributes. Withrelation=AUTHORIZERorANY,subjectIdidentifies the user who gave the consent, which may be someone other than the caller.A
400response is now documented on the listing operation.GET,POST /revokeandPOST /validateon/me/consents/{consent-id}now admit the consent subject or any user in the consent's authorization list; an unrelated user still receives 403. This means a listed authorizer can revoke the whole consent, including one who never approved it.Changes
consent.yamlupdated;src/genregenerated (newConsentPurposeSummary, extendedConsentSummary).MeApiServiceImplpassesrelationandattributesthrough.UserConsentService:listConsentstakesrelation(parsed toConsentRelation, defaulting toSUBJECTwhen blank) andattributes; the context username is passed as the user identifier.timestampaccepted in the filter attribute check, restricted toge/le.attributesparsed into a set, unknown values rejected with400 CM_00118.attributesis omitted.getConsent,revokeConsentandvalidateConsentnow callgetReceiptForInvolvedUserWithExtendedSchema.subjectIdset onConsentSummary.toAuthorizationResponses.