Lifecycle cleanups: M-1 mapping revoke, M-3 visibility warning, M-4 demotion sweep #111
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!111
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/lifecycle-cleanups"
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 #16. Three audit findings under the lifecycle / cascade-gap theme.
M-1 — group-mapping deletion left stale ProjectAccess
Dropping an LDAP/OAuth2 group mapping previously removed the mapping row but left the
project_accessrows that were granted via that source untouched. Until the affected user's next login (wheresyncProjectAccesswould have revoked the dangling row), they retained access — possibly indefinitely if they never logged in again.ProjectAccessStore.RevokeProjectBySource(projectID, source).handleAdminDeleteGroupMappingcalls it afterDelete. Surviving mappings that still cover the same(project, source)re-grant on the user's next login, so the dangling-grant window is bounded.M-3 — public → private/custom visibility flip leaves users locked out silently
Editors who had implicit access to a public project lose it the moment the project is restricted, with no signal to the admin doing the change.
handleAdminUpdateProjectrecords the previous visibility. On apublic → non-publictransition it appends?msg=visibility_restrictedto the redirect.handleAdminProjectsrenders the new flash: "Project visibility changed from public — review project access so the intended users still have access."M-4 — editor demotion left tokens and manual editor grants in place
A demoted user with leftover API tokens + their original auto-grant could still upload to projects via
canUpload's project-grant branch despite the role change.ProjectAccessStore.RevokeManualEditorByUser(userID).handleAdminUpdateUserRole: when the role transitions away from admin/editor to viewer, revoke the user's manual editor grants and delete all of their API tokens.Tests
Four regression tests in
lifecycle_cleanup_test.go:TestDeleteGroupMappingRevokesProjectAccess— pre-seeded oauth2-source access is gone after mapping deleteTestVisibilityRestrictionFlagsFlash— public→private redirect carries the flash; private→private edit does notTestDemotionRevokesManualEditorGrantsAndTokens— editor→viewer revokes bothTestPromotionDoesNotRevokeGrants— sanity: viewer→editor leaves existing grants alonesetupTestAppgainedGroupMappingsinDeps(it was missing, which the M-1 test caught by panicking on the nil store).Test plan
go test ./...passes/admin/robots(or wherever their token was listed) shows zero tokens🤖 Generated with Claude Code
Three audit findings under the lifecycle/cascade-gap theme. M-1 — Group-mapping deletion previously dropped the mapping row but left the project_access rows that were granted via that source untouched. Until the affected user's next login (which would re-run syncProjectAccess and revoke the dangling row), they retained access — possibly indefinitely if they never logged in again. Add ProjectAccessStore.RevokeProjectBySource(projectID, source). The group-mapping delete handler calls it after Delete. Surviving mappings that cover the same (project, source) re-grant on the user's next login, so the dangling-grant window is now bounded. M-3 — Visibility transition from public to private/custom leaves no grants in place. Editors who could see/upload to the now-non-public project lose access silently and the admin gets no signal. handleAdminUpdateProject captures the previous visibility, and when the project transitions away from public it appends ?msg=visibility_restricted to the redirect. The admin projects page renders that as a warning flash: "Project visibility changed from public — review project access so the intended users still have access." M-4 — Demoting an editor or admin to viewer leaves their previously- created API tokens valid and their manual editor-role project_access rows in place. canUpload's project-grant branch then accepts them, so the demoted user can still upload despite the role change. Add: - ProjectAccessStore.RevokeManualEditorByUser(userID) - In handleAdminUpdateUserRole, when role transitions away from admin/editor to viewer, revoke the user's manual editor grants and delete all of their API tokens. Four regression tests in lifecycle_cleanup_test.go covering each path plus a sanity test that promotion (viewer → editor) leaves grants untouched. setupTestApp gained GroupMappings in Deps (it was missing, which the M-1 test surfaced by panicking on the nil store). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>