-
Type:
Task
-
Resolution: Done
-
Priority:
Highest
-
Affects Version/s: None
-
None
-
AMRIT Sprint 37
-
Platform
-
All
Update the authentication middleware to handle both modern JWT-based tokens and legacy auth tokens. The implementation should follow the priority and fallback order as described below
Implementation Steps:
1.Check for JWT token in cookies:
- Look for a cookie (e.g., JwtToken in cookie).
- If valid, decode and authenticate.
2. Check JwtToken in header
- Look for a cookie (e.g., JwtToken in header).
- If valid, decode and authenticate.
3. Fallback to Authorization header with legacy auth token:
- If JWT not found in cookie or header, check the Authorization header.
- Extract the token part from the header (remove the {{Bearer }} prefix).
- Treat the token as a legacy auth token.
- Authenticate using the legacy token validation logic.
4.Error handling:
- If none of the above validations succeed, return appropriate 401 Unauthorized response.
Acceptance Criteria
- Old requests from currently deployed FLW app must get appropriate response when legacy auth token is sent in Authorization Bearer.
- New requests from existing FLW app under development sending JWT token in header must work.
- New requests from existing web interfaces must work (JWT in cookie).