Skip to content

feat: add authorization policies - #15

Merged
vinimachadosantana merged 6 commits into
developfrom
feat/authorization-policies
Aug 7, 2026
Merged

feat: add authorization policies#15
vinimachadosantana merged 6 commits into
developfrom
feat/authorization-policies

Conversation

@vinimachadosantana

Copy link
Copy Markdown
Owner

What

Adds Pundit policies for organisations, wires enforcement into the base controller, and adds policy and cross-tenant request specs.

Why

Authentication proves who someone is, it says nothing about what they may touch. Without policies, any signed-in user could read any organisation by guessing an ID.

How

  • Scope first, then authorize. Checking permission on an already-loaded record is the classic multi-tenant leak.
  • verify_authorized and verify_policy_scoped raise when an action forgets to authorise.
  • Cross-tenant access returns 404, not 403, so responses can't be used to enumerate which organisation IDs exist.
  • The policy spec covers admin, member and non-member.

Testing

  • Policy specs for all three roles
  • Request spec proves another tenant's organisation returns 404
  • RuboCop and Brakeman clean

@vinimachadosantana vinimachadosantana self-assigned this Aug 7, 2026
@vinimachadosantana
vinimachadosantana merged commit a7eb464 into develop Aug 7, 2026
3 checks passed
@vinimachadosantana
vinimachadosantana deleted the feat/authorization-policies branch August 7, 2026 14:08
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