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?
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).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With