feat: add scopes (CM-1333) - #4415
Conversation
PR SummaryMedium Risk Overview Router behavior: Every sub-router now uses Contract: Reviewed by Cursor Bugbot for commit 2d2a567. Bugbot is set up for automated code reviews on this repo. Configure here. |
There was a problem hiding this comment.
Pull request overview
Adds dedicated Auth0 M2M scopes for Akrites while temporarily retaining Self Serve scope compatibility.
Changes:
- Defines three Akrites-specific scopes.
- Applies alternative scope authorization across Akrites endpoints.
- Updates the OpenAPI security contract.
Required metadata fix: Update the incomplete title to feat: add Akrites M2M scopes (CM-1333).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
backend/src/security/scopes.ts |
Adds Akrites scope constants. |
backend/src/api/public/v1/akrites-external/index.ts |
Updates endpoint scope authorization. |
backend/src/api/public/v1/akrites-external/openapi.yaml |
Documents dedicated and fallback scopes. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
66be39c to
2d2a567
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
Comments suppressed due to low confidence (1)
backend/src/api/public/v1/akrites-external/openapi.yaml:25
- This says all three legacy scopes work on every operation, but the operation-level requirements are intentionally separated:
read:packagesdoes not authorize Contacts, andread:maintainer-rolesdoes not authorize Packages or Advisories. Rephrase this as operation-specific fallbacks so the API-level description does not contradict the requirements below.
scopes. Until Akrites cuts over to that client's credentials, the Self Serve
client's existing scopes (read:packages, read:stewardships,
read:maintainer-roles) still work on every operation below — each operation
lists both the new dedicated scope(s) and the old fallback scope(s) as
alternatives. Drop the old alternative once the cutover is confirmed.
Summary
Adds support for the new "Akrites Enclave" Auth0 M2M client on the
akrites-externalpublic API. The Akrites program is moving from the old Self Serve client to a
dedicated client with its own scopes (
read:akrites-packages,read:akrites-advisories,read:akrites-maintainers), but their consumer hasn'tcut over yet, so both the new dedicated scopes and the old Self Serve scopes are
accepted in parallel until the migration completes.
Changes
backend/src/security/scopes.ts:READ_AKRITES_PACKAGES,READ_AKRITES_ADVISORIES,READ_AKRITES_MAINTAINERS.akrites-external/index.ts(packages, advisories,contacts, blast-radius) to accept either the new dedicated scope or the old
Self Serve scope(s) via
requireScopes([...], 'any').read:packagesANDread:stewardshipstogether (
'all'mode); this is intentionally loosened to a flat'any'acrossall three scopes for now, since the old scopes will be dropped entirely once
Akrites' client cuts over — matches the pattern already used for the other
endpoint groups.
advisoriesScopesconst (advisories and blast-radius use theidentical scope list) to avoid duplicating the array, mirroring the existing
contactsScopespattern.openapi.yamlto document both the dedicated and fallback scopes onevery affected operation, tag description, and 403 response.
READ_PACKAGES,READ_STEWARDSHIPS,READ_MAINTAINER_ROLES) aretemporary here — drop them once Akrites' consumer migrates to the new client.
Type of change
JIRA ticket
CM-1333