-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(adapter-nextjs): use maxAge attribute to set cookie from server to avoid clock drift #14103
base: feat/server-auth/main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for addresing this! I only have one nit question.
@@ -22,5 +22,6 @@ export const PKCE_COOKIE_NAME = 'com.amplify.server_auth.pkce'; | |||
export const STATE_COOKIE_NAME = 'com.amplify.server_auth.state'; | |||
export const IS_SIGNING_OUT_COOKIE_NAME = | |||
'com.amplify.server_auth.isSigningOut'; | |||
export const AUTH_FLOW_PROOF_COOKIE_EXPIRY = 10 * 60 * 1000; // 10 mins | |||
export const AUTH_FLOW_PROOF_MAX_AGE = 10 * 60; // 10 mins in seconds | |||
export const REMOVE_COOKIE_MAX_AGE = -1; // -1 to remove the cookie immediately (0 ==> session cookie) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(0 ==> session cookie)
I'm curious whether this is a common behavior by the specs
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to MDN setting 0 should also make the cookie expire immediately - however, when I set the cookie from the server with 0, the cookie gets marked as session
, and remaining in cookie store until closing the tab.
43e6b22
to
48e7052
Compare
c850f31
to
ab50e6c
Compare
48e7052
to
6852abb
Compare
ab50e6c
to
61fd1d6
Compare
f7771ce
to
ce16bcd
Compare
…ver to avoid clock drift
61fd1d6
to
9069ee7
Compare
Description of changes
Use
maxAge
cookie attribute to set cookies from the server side to avoid clock drift issues.Since the access token usage are carried onto the server-side, and tokens expiries check and refresh are all performed on the server side of a Next.js app, the client-side incorrect system time becomes irrelevant.
Issue #, if available
Description of how you validated changes
Checklist
yarn test
passesChecklist for repo maintainers
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.