UPDATED FROM THE LAST QUESTION WITH MORE DETAILS
This app should be able to grant access to multiple files from salesforce.com to cloudfront using cloudfront signed cookies.
To do this, i've thought about building an aws lambda function exposed as a web-service from api gateway that will generate and return back the signed cookies in a HTTP Response Header to the js app.
Then, the salesforce js app should be able to call this function to fetch the signed cookies and redirect the user to the private content url on cloudfront.
- The function that generates the cookie is hosted on amazonws.com (Lambda function)
- The function that call the amazonws.com function is hosted on salesforce.com
- salesforce.com makes a
CORSto amazonws.com to get required cookies.
- For each returned cookie, amazonws.com set the attributes below:
- domain=cloudfront.net; path=/; secure; httpOnly
I successfully fetch the cookies on the client side (salesforce.com) from server side (amazonws.com) by reading the
XHR HTTP Response header .
But (and this is where i've spent the last 24 hours), the cookies are not set in the cookie store of the browser on salesforce.com. Which means they are not available for requesting resources to cloudfront.net.
Do you think that could work if my aws lambda function was on the same domain as cloudfront.net to serve a cookie with domain=cloudfront.net :
- awmazonws.com/myfunction would become cloudfront.net/myfunction
Or is there any other way to do this?
Thanks a lot for your support!