Skip to content

security: Router.Route ignores AuthUser — relies on middleware for enforcement #60

@cristim

Description

@cristim

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 validateSecurityauthenticate 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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions