In internal/api/router.go (Route method, ~line 213-231), the per-route Auth level is only checked when it equals AuthAdmin. Routes declared as Auth: AuthUser (e.g., /api/auth/logout, /api/api-keys, /api/federation/iac, and now /api/commitment-options from #54) fall through the if-block with no router-level auth check.
Currently these endpoints are still protected by validateSecurity → authenticate in handler.go, but that's an indirect safety net. A future refactor that reorders middleware, or a new route that bypasses validateSecurity, would silently expose every AuthUser endpoint.
Fix direction
- Add an
else if route.Auth == AuthUser branch in Router.Route that returns 401 when no valid session is present, independent of middleware ordering.
- Update the
AuthLevel doc comment at router.go:23 to accurately describe what enforcement happens where.
Surfaced during review of #54. Not blocking that PR.
In
internal/api/router.go(Routemethod, ~line 213-231), the per-routeAuthlevel is only checked when it equalsAuthAdmin. Routes declared asAuth: AuthUser(e.g.,/api/auth/logout,/api/api-keys,/api/federation/iac, and now/api/commitment-optionsfrom #54) fall through the if-block with no router-level auth check.Currently these endpoints are still protected by
validateSecurity→authenticateinhandler.go, but that's an indirect safety net. A future refactor that reorders middleware, or a new route that bypassesvalidateSecurity, would silently expose everyAuthUserendpoint.Fix direction
else if route.Auth == AuthUserbranch inRouter.Routethat returns 401 when no valid session is present, independent of middleware ordering.AuthLeveldoc comment atrouter.go:23to accurately describe what enforcement happens where.Surfaced during review of #54. Not blocking that PR.