You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Authorization today is ad-hoc booleans and stringly-typed flags duplicated across every layer:
Server: controllers re-implement isOwner / isCollaborator / 'view'|'edit' checks per endpoint (~6 sites in server/src/controllers/document.controller.ts alone), each with its own status-code choice (403 vs 401) and log action
Client: access.isOwner, access.isCollaborator, permission are threaded as parallel booleans through prop chains (document.tsx → DocumentHeader → DocumentToolbar → dropdowns)
Every new endpoint re-invents the rules — drift risk is exactly how #43 happened.
Proposal
Single server guard, e.g. requireDocumentAccess('owner' | 'editor' | 'viewer'), mounted on document routes; one shared resolver for "effective role of user X on doc Y"
Decide schema direction: role enum on Collaborator rows vs keeping ownership implicit in Document.authorId
Client consumes a single derived role from the /document/:idaccess payload instead of parallel booleans; UI gates map from role
Problem
Authorization today is ad-hoc booleans and stringly-typed flags duplicated across every layer:
isOwner/isCollaborator/'view'|'edit'checks per endpoint (~6 sites inserver/src/controllers/document.controller.tsalone), each with its own status-code choice (403 vs 401) and log actionaccess.isOwner,access.isCollaborator,permissionare threaded as parallel booleans through prop chains (document.tsx→DocumentHeader→DocumentToolbar→ dropdowns)onAuthenticatewill need the same role resolution again for read-only enforcementEvery new endpoint re-invents the rules — drift risk is exactly how #43 happened.
Proposal
requireDocumentAccess('owner' | 'editor' | 'viewer'), mounted on document routes; one shared resolver for "effective role of user X on doc Y"Collaboratorrows vs keeping ownership implicit inDocument.authorIdrolefrom the/document/:idaccesspayload instead of parallel booleans; UI gates map from roleonAuthenticatefor CRITICAL: Realtime sync ignores permissions (WS has no onAuthenticate) #24 readOnly enforcementAcceptance criteria
Related
#43, #24, #45