Skip to content

Feature/permission matrix#9641

Open
Daena-Crosby wants to merge 17 commits intoHumanSignal:developfrom
J-A-I-A:feature/permission-matrix
Open

Feature/permission matrix#9641
Daena-Crosby wants to merge 17 commits intoHumanSignal:developfrom
J-A-I-A:feature/permission-matrix

Conversation

@Daena-Crosby
Copy link
Copy Markdown

Pull Request Description

This PR introduces a canonical permission matrix with role‑based access control and audit logging. It defines two roles—Admin and Annotator—with granular permissions across eight resource types: Users, Projects, Tasks, Annotations, Labels/Taxonomy, Export, API Keys, and Audit Logs.

Key components include:

  • A versioned JSON configuration (permissions.json) serving as the single source of truth for all permission decisions.
  • JWT role embedding, extending LSAPIToken to include role information derived from Django Group membership.
  • An AuditLog model that records all permission denials with indexed fields for efficient querying.
  • A RoleBasedPermission guard class that enforces matrix rules, returns structured 403 errors, and logs denials.
  • Utilities for matrix lookups and performance‑optimized caching.
  • A test suite covering matrix logic, JWT payload verification, and audit logging integration.

Rollout Strategy

The rollout is staged in three phases. Phase 1, delivered in this PR, establishes the core infrastructure: the matrix, JWT role embedding, guards, and audit logging. Phase 2 will extend RoleBasedPermission to all remaining API routes. Phase 3 will add comprehensive integration tests to ensure 100% coverage of matrix combinations across endpoints.


Testing Status

Unit tests confirm correct matrix loading, role extraction, permission checks, and audit log creation. JWT payloads include roles for both admin and annotator users, and unauthenticated users default to annotator. AuditLog entries are correctly recorded. However, integration tests are missing, and many routes still lack RoleBasedPermission enforcement.


Risks and Notes

The most pressing risk is incomplete route protection: only six views are currently guarded, leaving more than twenty exposed. AuditLog volume may become significant in high‑traffic deployments, requiring monitoring and possible archiving. Role assignment is tied to Django Group membership, which may not scale to multi‑organization setups.

General notes emphasize that permissions.json must remain the single source of truth, with no hardcoded role checks elsewhere. Default role assignment follows the principle of least privilege, ensuring unassigned users cannot access restricted resources.


Reviewer Guidance

Reviewers should verify that permissions.json accurately reflects the intended permission matrix, confirm AuditLog indexing performance in staging, and ensure that Phase 2 applies RoleBasedPermission to all remaining views. JWT authorization headers should also be validated at the frontend or gateway level.


This structure makes the information easier to digest, highlighting the current state, what’s included, what’s missing, and what reviewers should focus on. Would you like me to also condense this into a short executive summary (like a one‑paragraph overview for leadership), or keep it detailed for technical reviewers?

@Daena-Crosby Daena-Crosby requested review from a team, hlomzik and nick-skriabin as code owners March 18, 2026 19:01
@netlify
Copy link
Copy Markdown

netlify bot commented Mar 18, 2026

👷 Deploy request for label-studio-docs-new-theme pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit d04a74b

@netlify
Copy link
Copy Markdown

netlify bot commented Mar 18, 2026

👷 Deploy request for heartex-docs pending review.

Visit the deploys page to approve it

Name Link
🔨 Latest commit d04a74b

@netlify
Copy link
Copy Markdown

netlify bot commented Mar 18, 2026

Deploy Preview for label-studio-storybook ready!

Name Link
🔨 Latest commit d04a74b
🔍 Latest deploy log https://app.netlify.com/projects/label-studio-storybook/deploys/69baf6724c1cd40008e374f7
😎 Deploy Preview https://deploy-preview-9641--label-studio-storybook.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify
Copy link
Copy Markdown

netlify bot commented Mar 18, 2026

Deploy Preview for label-studio-playground ready!

Name Link
🔨 Latest commit d04a74b
🔍 Latest deploy log https://app.netlify.com/projects/label-studio-playground/deploys/69baf672055e6f0009a8a1b8
😎 Deploy Preview https://deploy-preview-9641--label-studio-playground.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants