feat(api): per-map edit permissions + protected maps + attribution (#4) - #360
feat(api): per-map edit permissions + protected maps + attribution (#4)#360Aduersarius wants to merge 1 commit into
Conversation
…bution (Bitcoindefi#4) Extend GAME_DATA_ADMIN_* to map mutations with collaborator grants in game_map_permissions, block capital maps unless x-protected-map-override, and append who/what/when to game_map_mutation_log on every write.
|
Hi @Aduersarius — I checked head The six assertions run through I could help with a complementary follow-up in Would this separate integration-test scope be useful to you, and can a maintainer point me to an assignable campaign task if it is eligible? I will wait for assignment before opening a PR and follow the campaign platform's reward process; I am not claiming the implementation already in this PR. Disclosure: this review and proposed contribution are AI-assisted, performed on behalf of |
Summary
Resolves #4 — Etapa 0 permissions and attribution for map editing.
What landed
requireMapEditSession: sameGAME_DATA_ADMIN_PROXY_TOKENgate; superadmin via email/account; collaborators viagame_map_permissions(map_num or0= all non-protected).{1, 34, 59, 150}: rejected for everyone unless superadmin sendsx-protected-map-override: true.game_map_mutation_logrecords who/what/when on paint, clear, entities, publish, discard, revert, grant/revoke (complementsupdated_by_account_idon row writes).GAME_DATA_ADMIN_*inapi/.env.example.npx tsx --test src/tests/mapEditPermissions.test.ts→ 6/6 covering all four acceptance cases as pure decision logic.Differentiation vs open PRs
isSuperAdmin: true— collaborators never work; no DB grants table; contaminated with graceful-shutdown unrelated filesservices/map-permissions.tswith fictionalassignedMaps; not wired to real admin/session or map routesThis PR keeps permission decision pure (
mapEditPermissions.ts), persists grants + audit in schema, and wires every map mutation route consistently via one header.Test plan
cd api && npx tsx --test src/tests/mapEditPermissions.test.ts(6/6)api/schema.sql(game_map_permissions,game_map_mutation_log)PUT .../maps/50/tiles→ 403x-protected-map-override: true→ okgame_map_mutation_log