Skip to content

Unify auth middleware to a single implementation (JWT verify + DB session) #158

@robertocarlous

Description

@robertocarlous

Problem

There are two authentication middlewares with overlapping responsibility (src/middleware/auth.ts and src/middleware/authenticate.ts). Some routes use one, others use the other, increasing the risk of inconsistent enforcement (JWT verification, session expiry, user isActive checks, etc.).

Acceptance criteria

  • Choose one canonical middleware
  • Ensure it ALWAYS validates JWT signature + checks DB session existence + expiry + user.isActive
  • Migrate all routes to the canonical middleware
  • Delete or deprecate the duplicate implementation
  • Update tests to match the single path

export async function requireAuth(

export class AuthMiddleware {
static validateJwt = async (

Priority

P0 / Critical

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