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
There is a function to validate a JWT token passed in the QueryString, but is there a way to decrypt a cookie as well?
What I am attempting to do is decrypt a cookie, check the information for the user in said cookie and add a header that identifies the user as authenticated.
The function would then add a header to the request identifying the user as such. This would allow us to serve protected content cached at CloudFront as opposed to going deeper into our stack.
The text was updated successfully, but these errors were encountered:
cookies are part of the event. Let's assume your cookie that holds the JWT is called "JWT". Then you code could look like this (untested!)
functionhandler(event){constrequest=event.request;consturi=request.uri;constcookies=request.cookiesif(cookies&&cookies["JWT"]){consttokenCookie=cookies["JWT"]constjwtToken=tokenCookie.valuetry{jwt_decode(jwtToken,key);}catch(e){console.log(e);returnresponse401;}console.log("Valid JWT token");returnrequest;}// no cookies?returnresponse401;}
There is a function to validate a JWT token passed in the QueryString, but is there a way to decrypt a cookie as well?
What I am attempting to do is decrypt a cookie, check the information for the user in said cookie and add a header that identifies the user as authenticated.
The function would then add a header to the request identifying the user as such. This would allow us to serve protected content cached at CloudFront as opposed to going deeper into our stack.
The text was updated successfully, but these errors were encountered: