Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access URL fragment in Lambda Node.js function

I have an S3 website that I'm trying to password-protect using a Lambda function and CloudFront. When a user tries to access the site, the Lambda function will redirect them to my Cognito login page, then redirect back to the site with a token.

When redirecting back, the access token is in the fragment (after "#"). Is it possible to obtain this token in the Lambda function using Node.js?

like image 928
syim Avatar asked Nov 03 '25 05:11

syim


1 Answers

No, it isn't. The fragment is only available to JS running on the browser -- it's never sent to any web server.

There's an example here of one way to get it, as mentioned in Authorization@Edge – How to Use Lambda@Edge and JSON Web Tokens to Enhance Web Application Security, which uses Lambda@Edge rather than API Gateway (the two services have some overlapping functionality).

like image 137
Michael - sqlbot Avatar answered Nov 06 '25 03:11

Michael - sqlbot



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!