You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
returnres.boom.forbidden("Only viewing is permitted during impersonation");
35
+
}
36
+
}
37
+
20
38
if(roles&&roles.restricted&&req.method!=="GET"){
21
39
returnres.boom.forbidden("You are restricted from performing this action");
22
40
}
41
+
23
42
returnnext();
24
43
};
25
44
26
45
/**
27
-
* Middleware to validate the authenticated routes
28
-
* 1] Verifies the token and adds user info to `req.userData` for further use
29
-
* 2] In case of JWT expiry, adds a new JWT to the response if `currTime - tokenInitialisationTime <= refreshTtl`
46
+
* Authentication middleware that:
47
+
* 1. Verifies JWT token from cookies (or headers in non-production).
48
+
* 2. Handles impersonation if applicable.
49
+
* 3. Refreshes token if it's expired but still within the refresh TTL window.
50
+
* 4. Attaches user data to `req.userData` for downstream use.
30
51
*
31
-
* The currently implemented mechanism satisfies the current use case.
32
-
* Authentication with JWT and a refreshToken to be added once we have user permissions and authorizations to be handled
33
-
*
34
-
* @todo: Add tests to assert on refreshed JWT generation by modifying the TTL values for the specific test. Currently not possible in the absence of a test-suite.
35
-
*
36
-
*
37
-
* @param req {Object} - Express request object
38
-
* @param res {Object} - Express response object
39
-
* @param next {Function} - Express middleware function
40
-
* @return {Object} - Returns unauthenticated object if token is invalid
0 commit comments