visamasteractions: register /:id/actions as its own rbac prefix
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:
guwandykandClaude Opus 5.5 committed 2026-10-25 22:46:43 +05:00
1 parent 11e1fa4972
commit 41ae56240a
3 files changed
+48 -11

No files matched your search

+13 -7
View File
@@ -74,6 +74,19 @@ func New(cfg *config.Config, client *pgxpool.Pool, logger *logging.Logger) *gin.
}
adminGroup.Use(rbac.Guard(rbac.NewService(client)))
registerRoutes(router, adminGroup, cfg, client, logger)
// Deny by default: every admin route must declare its policy via rbac.Group.
if err := rbac.VerifyRoutes(router.Routes(), adminAPIPrefix); err != nil {
logger.Fatal(err)
}
return router
}
// registerRoutes has every bounded context register its handlers. rbac
// panics here if two groups declare different policies for one prefix.
func registerRoutes(router *gin.Engine, adminGroup *gin.RouterGroup, cfg *config.Config, client *pgxpool.Pool, logger *logging.Logger) {
// Each bounded context registers its own modules' handlers.
// Add new modules inside the relevant context's router.go rather than here.
identity.Register(adminGroup, router, client, logger)
@@ -94,13 +107,6 @@ func New(cfg *config.Config, client *pgxpool.Pool, logger *logging.Logger) *gin.
logger,
)
backup.NewHandler(logger, backupSvc).Register(adminGroup)
// Deny by default: every admin route must declare its policy via rbac.Group.
if err := rbac.VerifyRoutes(router.Routes(), adminAPIPrefix); err != nil {
logger.Fatal(err)
}
return router
}
// paymentGatewayClient picks the real GBÜS client outside debug mode, and