Skip to content

Instantly share code, notes, and snippets.

@darbelaez
Last active July 11, 2024 13:17
Show Gist options
  • Save darbelaez/d5b802a8f0600076a3f19fc0161a367e to your computer and use it in GitHub Desktop.
Save darbelaez/d5b802a8f0600076a3f19fc0161a367e to your computer and use it in GitHub Desktop.
AWS Signed Cookie from Signed URL cross domain
@darbelaez
Copy link
Author

@Ivthillo this file would be placed in the CloudFront site it self (the starting page) where your Signed URL is redirecting the user to. The flow would look something like this...

  • website 1 would generate a Signed URL to website 2 (CloudFront) the user can click on or redirected to automatically (i.e. http://mysite.com/landing.html)

  • website 2's "landing.html" file should contain the javascript noted above. This will allow website 2 to switch from using the signed url to now use Signed Cookies based on the information from the Signed URL.

Home this helps

@lvthillo
Copy link

@darbelaez Thank you for the info. Did the setup but it seems the script expects a signed URL with a custom policy. Is this a requirement or can this work with a canned policy too?

@lvthillo
Copy link

Thanks, got it working with the signed URL with custom policy. After doing it, it became clear how the custom policy is used by the signed cookies.

@darbelaez
Copy link
Author

Thanks, got it working with the signed URL with custom policy. After doing it, it became clear how the custom policy is used by the signed cookies.

Yes! forgot to mention that - i was using a Custom policy - did not try it with a Canned policy but i'm it can be made to work with one with some minor modification. Glad to hear it's working for you.

@Ba-sunith
Copy link

How does this work for SPA applications?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment