feat: Enforce API token scopes from the route map
Keyed on the registered gin route pattern rather than a per-route decorator, because a route registered without a decorator would be unguarded. An unmapped route reached by a token is a 403, and a boot-time check refuses to start when any /api route is missing, so the failure lands at deploy rather than as a customer's surprise 403.
This commit is contained in:
@@ -234,6 +234,10 @@ func serve() {
|
||||
r.Use(corsMiddleware())
|
||||
api.RegisterRoutes(r)
|
||||
|
||||
if err := api.AssertScopeMapComplete(r); err != nil {
|
||||
log.Fatalf("api scope map: %v", err)
|
||||
}
|
||||
|
||||
srv := &http.Server{Addr: ":8080", Handler: r}
|
||||
go func() {
|
||||
log.Println("REST server listening on :8080")
|
||||
|
||||
Reference in New Issue
Block a user