Skip to content

Improve Firebase authentication and cookie handling - #14603

Open
vidhishav-sudo wants to merge 3 commits into
GoogleCloudPlatform:mainfrom
vidhishav-sudo:patch-1
Open

vidhishav-sudo wants to merge 3 commits into
GoogleCloudPlatform:mainfrom
vidhishav-sudo:patch-1

Conversation

@vidhishav-sudo

Copy link
Copy Markdown

Fix Firebase Auth UI race condition in App Engine tutorial

Description

Fixes #

Checklist

Testing

  • I have tested this change on a live environment and verified it works as intended.

Compliance & Style


Post-Approval Actions

  • Please merge this PR for me once it is approved

Fix Firebase Auth UI race condition in App Engine tutorial
@vidhishav-sudo
vidhishav-sudo requested review from a team as code owners September 15, 2026 12:12
@product-auto-label product-auto-label Bot added samples Issues that are directly related to samples. api: appengine Issues related to the App Engine Admin API API. labels Sep 15, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the Firebase authentication flow in script.js by initializing the FirebaseUI Widget outside of onAuthStateChanged to prevent multiple instantiation errors, adding a callback to set the ID token cookie globally upon successful sign-in, and safely clearing the cookie on sign-out. The review feedback suggests adding a .catch() block to the getIdToken() promise to prevent the UI from hanging on failure, and explicitly setting the SameSite=Lax attribute when both setting and clearing the token cookie to enhance security against CSRF attacks.

Comment thread appengine/standard_python3/building-an-app/building-an-app-3/static/script.js Outdated
Comment thread appengine/standard_python3/building-an-app/building-an-app-3/static/script.js Outdated
vidhishav-sudo and others added 2 commits September 15, 2026 17:46
…tatic/script.js

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
…tatic/script.js

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: appengine Issues related to the App Engine Admin API API. samples Issues that are directly related to samples.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant