Skip to content

security: add admin role authorization to /api/v1/admin/* endpoints #75

@aaronbrethorst

Description

@aaronbrethorst

Problem

The admin user management routes (/api/v1/admin/users/*) added in #57 use requireAuth middleware, which only validates that the JWT is signed and unexpired. It does not check the caller's role. Any authenticated driver can create, delete, and modify all user accounts — including promoting themselves to admin or deleting other admins.

Suggested Fix

The JWT already contains a role claim (set in auth.go during login). Add a requireAdmin middleware (or role-checking wrapper) that reads claims["role"] from the context and returns 403 if it's not "admin". Apply it to all five admin routes in main.go:85-89.

References

  • main.go:85-89 — routes that need protection
  • auth.go:116-150 — existing requireAuth middleware to extend

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions