-
Notifications
You must be signed in to change notification settings - Fork 918
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
Auth cookie persistence #8839
Auth cookie persistence #8839
Conversation
🦋 Changeset detectedLatest commit: 1e50af6 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
packages/auth/src/platform_browser/persistence/cookie_storage.ts
Outdated
Show resolved
Hide resolved
packages/auth/src/platform_browser/persistence/cookie_storage.ts
Outdated
Show resolved
Hide resolved
packages/auth/src/platform_browser/persistence/cookie_storage.ts
Outdated
Show resolved
Hide resolved
packages/auth/src/platform_browser/persistence/cookie_storage.ts
Outdated
Show resolved
Hide resolved
@@ -136,6 +136,7 @@ | |||
"@rollup/plugin-strip": "2.1.0", | |||
"@types/express": "4.17.21", | |||
"chromedriver": "119.0.1", | |||
"cookie-store": "4.0.0-next.4", |
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.
FYI using this dev-dep for types, somewhere else I tried this ponyfill and found it unsuitable for prod as it can't be webpacked.
packages/auth/src/platform_browser/persistence/cookie_storage.ts
Outdated
Show resolved
Hide resolved
This comment was marked as resolved.
This comment was marked as resolved.
Size Report 1Affected Products
Test Logs |
Size Analysis Report 1This report is too large (139,584 characters) to be displayed here in a GitHub comment. Please use the below link to see the full report on Google Cloud Storage.Test Logs |
@sam-gc @DellaBitta @hsubox76 PTAL at the latest iteration, cleaned up a lot. I'll be adding comments, fixing the test I broke with the function rename, and addressing my last few TODOs in the next change-set. |
// persistenceMananger to be available. see _getFinalTarget for more context | ||
this._persistenceManagerAvailable = new Promise<void>( | ||
resolve => (this._resolvePersistenceManagerAvailable = resolve) | ||
); |
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.
Can i haz Promise.withResolvers
yet? 🤣
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.
LG, just a tiny nit!
go/firebase-auth-cookie-persistence, pair with this NextJS middleware.
Demo here—login restricted to
@google.com
Google accounts.go/firebase-cookie-auth-bug-bash for bug bash instructions / feedback.
Principles of operation:
COOKIE
/__cookie__
, which is handled by the NextJS middleware. The middleware this redacts the refreshToken and stores it in an HTTP-only cookie, the idToken is stored in an JS-readable cookiegetCurrentUser()
internally can accept an idToken and will initiated a fetch request to get the user-details""
and will make a best-effort attempt to hit/__cookie__
, the middleware treats the blank string as a logout and will delete the refreshToken cookie if seenThere's a lot to clean up here, some high level things that need to be addressed