visamasteractions: register /:id/actions as its own rbac prefix
Some checks failed
CI/CD / Vet, test, build (push) Has been cancelled
CI/CD / Docker image (push) Has been cancelled
CI/CD / Deploy binary to server (push) Has been cancelled

The server panicked at startup: the actions group declared
require-staff:cards for /visa-master-payment-orders, which
cards/visamaster already registers with require:cards, and rbac allows
one policy per prefix. The group is now /visa-master-payment-orders/:id/actions,
the same way /callback has its own prefix; the routes are unchanged.

manager.New's handler registration moves into registerRoutes, and
TestRegisterRoutes runs it without a database, so a conflicting policy
fails the tests instead of the server.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-25 22:46:43 +05:00
parent 11e1fa4972
commit 41ae56240a
3 changed files with 48 additions and 11 deletions

View File

@@ -27,11 +27,13 @@ func NewHandler(logger *logging.Logger, repository Repository) handlers.Handler
}
// Register only wires read endpoints: actions are recorded by the
// repositories that change orders, never through the API.
// repositories that change orders, never through the API. The group is
// its own /:id/actions prefix because rbac allows one policy per prefix
// and cards/visamaster already declares require:cards for baseURL.
func (h *handler) Register(router *gin.RouterGroup) {
group := rbac.Group(router, baseURL, rbac.RequireStaff(perm.Cards))
group.GET("/:id/actions", h.list)
group.GET("/:id/actions/:actionId", h.get)
group := rbac.Group(router, baseURL+"/:id/actions", rbac.RequireStaff(perm.Cards))
group.GET("", h.list)
group.GET("/:actionId", h.get)
}
// list godoc