fix(gateway): require admin scope for config write endpoints#509
Conversation
- Add RequireAdminScope() helper to ConfigController - Apply to UpdateSection, UpdateSectionEntry, DeleteSectionEntry - Non-admin calleridentity returns 403; no identity (dev mode) passes through - GatewayAuthMiddleware.CallerIdentityItemKey promoted to public const - 7 new tests covering admin/non-admin/no-identity paths Closes #506
sytone
left a comment
There was a problem hiding this comment.
Farnsworth Review — PR #509
CI: ⏳ Pending (just opened)
Merge conflicts: ✅ Clean (MERGEABLE)
Conventional commit title: ✅ fix(gateway): require admin scope for config write endpoints
Test coverage:
- ✅ UpdateSection: admin 200, non-admin 403, no-identity 200
- ✅ UpdateSectionEntry: admin 200, non-admin 403
- ✅ DeleteSectionEntry: admin 200, non-admin 403
- 7 new tests; 1513/1513 gateway pass
Spec completeness vs #506: Satisfies all AC. Config write endpoints (PUT, DELETE) now require IsAdmin=true. Human portal sessions (dev mode, no identity) pass through for backward compatibility. Agent sessions without IsAdmin=true receive 403.
Note: Exec approval is via SignalR hub commands (not REST), so not covered here — separate concern if needed.
LGTM.
|
Closing as part of a planned hard-reset of the in-flight branch set so the new domain-model refactor can land on a clean trunk. Audit verdict: security Rationale: SECURITY FIX. The underlying authorization-scope gap remains in main after closure - must be re-applied as a fresh PR. See #506. The new plan (in session state) reshapes core types: Citizen (User+Agent union), Vogen-generated value objects, ThreadId removed in favour of composite ChannelAddress, mark-not-delete compaction, centralised If this work is still wanted, refile as a new issue/PR against the post-refactor contracts. |
Closes #506
Changes
ConfigController.UpdateSection,UpdateSectionEntry,DeleteSectionEntrynow callRequireAdminScope()before proceedingGatewayCallerIdentityreturns 403 Forbidden with{error: "forbidden", message: "Admin scope required for config write operations."}HttpContext.Items(dev mode / auth disabled) are allowed through — backward compatibleGatewayAuthMiddleware.CallerIdentityItemKeypromoted frominternaltopublic constso tests and future consumers can reference it without string literalsTest Results
7 new tests pass. 1513/1513 gateway tests pass (no regressions).