RBAC: opt-in `defaultPolicy: deny` for routes no rule covers
Is your feature request related to a problem? Please describe.
RBAC only enforces routes that a rule matches. A request to a registered route with no matching rule is allowed through (pkg/gofr/rbac/middleware.go, the endpoint == nil branch). So a new route added without a matching rule in rbac.json is public by default, and nothing fails. #3935 adds a startup warning that lists these uncovered routes, but the route is still served without role checks.
Describe the solution you'd like
An opt-in config field, for example "defaultPolicy": "deny". With it set, a request to a route that no rule covers is rejected with 403 instead of being allowed. GoFr's own /.well-known/* routes stay exempt, so health checks keep working. The default stays allow, so existing apps do not change.
A possible bridge: a release where deny only logs what it would have rejected (warn), so operators can find the gaps before enforcing.
Describe alternatives you've considered
- Listing every route in
rbac.jsonby hand. This is what apps do today, and it is the drift that #3935 reports on. - Making deny the default. That would be a breaking change, so it belongs in a major release at the earliest.
Additional context Follow-up to #3935 (startup route-coverage check) and #3763 (auth fails open when the config cannot be loaded).
Source: gofr-dev/gofr