Server - Technical Reference - v26.4.1
    Preparing search index...

    Function createAuthMiddleware

    • Middleware to enforce authentication and manage token rotation.

      1. Get access and refresh token
      2. check if access token is valid
      3. if invalid access token check is refresh token is valid
      4. if refresh token is valid regenerate access token
      5. if there is a cache data via user id get data for access token payload
      6. if no cache fetch from database and cache in redis

      Parameters

      Returns (req: Request, res: Response, next: NextFunction) => Promise<void>

      401 Unauthorized if both tokens are invalid or user lacks Admin permissions.