Skip to content

feat: make SQL writes a permission (EXECUTE_WRITES) so custom roles can write - #131

Merged
geekypunk merged 1 commit into
mainfrom
feat/writes-permission
Nov 7, 2026
Merged

geekypunk merged 1 commit into
mainfrom
feat/writes-permission

Conversation

@geekypunk

Copy link
Copy Markdown
Contributor

Why

Writes were gated on the built-in ADMIN or DBA role name, in both AccessControlService.currentUserMayMutateSql and the frontend's useAuth. A custom role could never write. That made it impossible to give EXECUTE_DDL (added in #130) to only some DBAs: a custom "DBA + schema changes" role would lose UPDATE/INSERT/DELETE entirely.

What changes

  • New EXECUTE_WRITES permission, held by ADMIN and DBA by default, so no one's access changes on deploy.
  • The backend and frontend gates check the permission, not the role name. A DBA whose EXECUTE_WRITES is revoked by an override can no longer write; a custom role granted it can.
  • No re-login needed. Every authentication path (JWT, MCP token, View-as) loads effective permissions as authorities per request, so the check takes effect immediately.
  • The Editor's "DBA mode" label is now "Write mode", since custom roles can see it.

Test plan

  • AccessControlServiceTest uses production-shaped authorities (ROLE_* plus permission names), with new cases for a custom role granted writes and a role name alone granting nothing
  • 80 tests across the auth, policy and safety-scanner suites
  • eslint: 0 errors
  • After deploy, create a custom role with DBA permissions plus EXECUTE_WRITES and EXECUTE_DDL, and assign it to the DBAs who need schema changes

🤖 Generated with Claude Code

…an write

Writes were gated on the built-in ADMIN or DBA role name, in the backend
(AccessControlService.currentUserMayMutateSql) and the frontend (useAuth).
A custom role could therefore never write, which also made EXECUTE_DDL
impossible to hand to a subset of DBAs: a 'DBA + schema changes' role
lost UPDATE/INSERT/DELETE entirely.

EXECUTE_WRITES defaults to ADMIN and DBA, so nobody's access changes.
Every authentication path (JWT, MCP token, View-as) carries effective
permissions as authorities, loaded per request, so the check takes
effect without re-login. The Editor's 'DBA mode' label becomes
'Write mode' since custom roles can now see it.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@geekypunk
geekypunk merged commit 9232dc4 into main Nov 7, 2026
9 checks passed
@geekypunk
geekypunk deleted the feat/writes-permission branch November 7, 2026 19:10
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