Skip to content

OBJ-98 — Authorization policy in all read/write paths - #39

Merged
objectgyan merged 1 commit into
mainfrom
objectgyan/obj-98-m9b3-authorization-policy-callback-in-all-readwrite-paths
May 17, 2026
Merged

objectgyan merged 1 commit into
mainfrom
objectgyan/obj-98-m9b3-authorization-policy-callback-in-all-readwrite-paths

Conversation

@objectgyan

Copy link
Copy Markdown
Owner

Summary

  • Implements DefaultAuthorizationPolicy with tenant check + owner/share-role hierarchy (editor → commenter → viewer)
  • Updates AuthorizationAction enum: Write renamed to Edit, Comment added
  • Wires IAuthorizationPolicy.AuthorizeAsync into all document read/write endpoints (GET/PUT/DELETE docs, versions, diff, restore, comments, replies, comment resolve, WS, PDF export, shares list)
  • Keeps AllowAllAuthorizationPolicy in Infrastructure for test override compatibility (existing tests unchanged)
  • 403 failures return { code: "forbidden" } JSON body

Test plan

  • 282/282 tests pass (160 unit + 122 integration)
  • 16-case persona × action integration test matrix in AuthzPolicyMatrixTests.cs
  • scripts/validate-obj-98.ps1 exits 0 — live API + DB assertions pass
  • validation/obj-98-api.txt — 12-case matrix verified
  • validation/obj-98-db.txt — DB unchanged after blocked write

- Add DefaultAuthorizationPolicy with owner + role hierarchy (editor/commenter/viewer)
- Update AuthorizationAction enum: rename Write→Edit, add Comment
- Wire IAuthorizationPolicy.AuthorizeAsync into all document read/write endpoints
- Keep AllowAllAuthorizationPolicy for test override compatibility
- Add 16-case persona × action integration test matrix (AuthzPolicyMatrixTests)
- Add scripts/validate-obj-98.ps1 + validation artifacts
@linear-code

linear-code Bot commented May 17, 2026 •

Copy link
Copy Markdown
OBJ-98 M9b.3 — Authorization policy callback in all read/write paths

Milestone: M9 · Wave: 3

Summary

Implement IAuthorizationPolicy.Authorize(user, document, action) and call it on every read + write path. Default policy uses tenant + owner + shares + role hierarchy.

Acceptance

  • Endpoints reject with 403 when policy returns deny
  • Editor role can edit; commenter can comment but not edit; viewer can only read
  • Host can override policy via DI

Validation

  • DB check: failed write attempt leaves DB unchanged
  • Live API check: 4 personas × 3 actions matrix asserted via integration test (12 cases)
  • Script: scripts/validate-obj-NNN.ps1

Branch / PR

Branch from main; target main. No trailers/footer.

Review in Linear

@objectgyan
objectgyan merged commit d0d32cb into main May 17, 2026
2 of 4 checks passed
objectgyan added a commit that referenced this pull request May 17, 2026
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