Fix inline authz drift (H-1, H-2) and project-scoped tokens creating projects (H-3) #106
No reviewers
Labels
No labels
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
qwc-open/asiakirjat!106
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/inline-authz-and-token-scope"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Workstream item #11. Three small fixes the
access.Checkerrefactor (#105) unblocked.H-1 —
handleDeleteVersionignored global-access grantsThe inline check (admin/editor OR per-project ProjectAccess) didn't honor
GlobalAccessGrant. A user with a global editor grant couldcanUploadto a private project but not delete versions of it. Replaced withh.canUpload(...).H-2 —
handleProjectDetailCanUpload/CanDeleteflag driftRecomputed the same inline rule for the template flag, so the UI hid affordances from users who could in fact POST to the underlying routes. Replaced with
h.canUpload(...).H-3 — project-scoped tokens could create unrelated projects
handleAPICreateProjectcalledtokenAuth.AuthenticateRequest, which silently discards the token'sProjectIDscope. A project-scoped editor token (created via/project/{slug}/tokens) could therefore hitPOST /api/projectsand spawn new top-level projects. AddedTokenAuthenticator.AuthenticateRequestWithToken(r) (*User, *APIToken)and the handler now rejects tokens with non-nilProjectIDwith 403.Changes
internal/auth/token.go— newAuthenticateRequestWithToken.internal/handler/project.go—handleDeleteVersionand theCanUploadflag inhandleProjectDetailboth callh.canUpload(...).internal/handler/api.go—handleAPICreateProjectuses the new auth method and rejects scoped tokens.internal/handler/handler_test.go—setupTestAppwas missingGlobalAccessinDeps, so the test handler had a nilglobalAccessstore. Added (needed for the H-1/H-2 regression tests).inline_authz_test.go.Test plan
go test ./...passes🤖 Generated with Claude Code