visamasteractions: register /:id/actions as its own rbac prefix
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user