cloudfront-auth
cloudfront-auth copied to clipboard
redirect_uri is fixed to "_/callback" despite setting otherwise during ./build.sh
Hi I've been trying to use this library to set up Google Oauth on our S3 bucket - Cloudfront.
Unfortunately, I've been getting "JWT error, unauthorized" message on the log with no JWT being set.
I found via debugging and testing with ngrok that request.uri
in Callback Payload is somehow fixed to "/_callback" even though it explicitly set it to https://our-cloudfront's-cname/index.html
, during ./build.sh
*/ Callback Payload /*
{
"Records": [
{
"cf": {
"request": {
"headers": {
"host": [ { "value": "example.com", "key": "Host" } ],
"user-agent": [ { "value": "test-agent", "key": "User-Agent" } ]
},
"clientIp": "2001:cdba::3257:9652",
"uri": "/_callback",
"method": "GET",
"querystring": "code=8fce8bc8b73510e11f8c&state=%2f&session_state=fc350b67-673e-4ecd-98e7-3c2f5a875d0a"
},
"config": {
"distributionId": "EXAMPLE",
"test": "https://9889643ae09c.ngrok.io"
}
}
}
]
}
My workaround is:
- changing the filename of s3's
index.html
to_callback
- changing redirect on OAuth provider to
https://my-cloudfront-cname.com/_callback
(I'm using cname because I'm using custom domain) - changing s3 - Properties - Static website hosting - set Index document to
_callback
- Make sure all files in S3 are set to public, but set OAI from cloudfront for making sure only access from cloudfront is allowed.
It works for now, I cannot figure out why this is happening. Thanks.