Skip to content

PM-4211: merge M2M member scopes across auth layers#13

Open
jmgasper wants to merge 1 commit intodevfrom
PM-4211-1
Open

PM-4211: merge M2M member scopes across auth layers#13
jmgasper wants to merge 1 commit intodevfrom
PM-4211-1

Conversation

@jmgasper
Copy link
Copy Markdown
Contributor

@jmgasper jmgasper commented Apr 3, 2026

What was broken
M2M POST, PATCH, and DELETE requests for project members could still return 403 when the raw token payload carried project-member write scope but the normalized user scope list did not fully match it.

Root cause (if identifiable)
PermissionService preferred user.scopes over the raw token payload, while TokenRolesGuard evaluates the raw token payload directly. When those two scope sources drifted, the write routes could pass the auth guard and still fail inside project-member permission checks.

What was changed
PermissionService now merges scopes from user.scopes and the raw token payload before evaluating named permissions, so M2M project-member write checks use the same effective grants across the guard and service layers.
Added a focused regression for create, update, and delete project-member permissions when tokenPayload.scope is broader than user.scopes.

Any added/updated tests
Updated src/shared/services/permission.service.spec.ts with create, update, and delete project-member M2M regression coverage for mismatched scope sources.
Validation run: pnpm lint, pnpm build, pnpm test -- src/shared/services/permission.service.spec.ts, and pnpm test:e2e -- --runInBand test/project-member.e2e-spec.ts passed.
pnpm test still fails in unrelated metadata event-publishing specs already failing on the current dev baseline.

What was broken
M2M POST, PATCH, and DELETE requests for project members could still return 403 even when the raw token payload carried project-member write scope.

Root cause (if identifiable)
The permission layer preferred user.scopes when they were present, while the route guard evaluated scopes from the raw token payload. If those two scope sources drifted, the guard could admit the request and the project-member service could still reject it.

What was changed
Merged normalized scopes from both user.scopes and the raw token payload in PermissionService so downstream permission checks use the same effective M2M grants that the auth guard sees.
Added a regression that covers create, update, and delete project-member permissions when the raw token payload is broader than user.scopes.

Any added/updated tests
Updated src/shared/services/permission.service.spec.ts with create, update, and delete project-member M2M regression coverage for mismatched scope sources.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant