Skip to content

Add support for running the emulators in Cloud Workstation #8968

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

Open
wants to merge 63 commits into
base: main
Choose a base branch
from

Conversation

maneesht
Copy link
Contributor

If an app is connected to Firebase Studio, then we should use credentials along with each request, to ensure that the auth cookie for the workstation is forwarded to each request in the emulator.

Products Affected:

  • RTDB
  • Data Connect
  • Auth
  • Firestore

Copy link

changeset-bot bot commented Apr 23, 2025

🦋 Changeset detected

Latest commit: e61c657

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 30 packages
Name Type
@firebase/app-check Patch
@firebase/auth Patch
@firebase/data-connect Patch
@firebase/database-compat Patch
@firebase/database Patch
@firebase/firestore Patch
@firebase/storage Patch
@firebase/util Patch
@firebase/app-check-compat Patch
firebase Patch
@firebase/auth-compat Patch
@firebase/firestore-compat Patch
@firebase/storage-compat Patch
@firebase/analytics-compat Patch
@firebase/analytics Patch
@firebase/app-compat Patch
@firebase/app Patch
@firebase/component Patch
@firebase/database-types Patch
@firebase/functions-compat Patch
@firebase/functions Patch
@firebase/installations-compat Patch
@firebase/installations Patch
@firebase/messaging-compat Patch
@firebase/messaging Patch
@firebase/performance-compat Patch
@firebase/performance Patch
@firebase/remote-config-compat Patch
@firebase/remote-config Patch
@firebase/vertexai Patch

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

Copy link
Contributor

github-actions bot commented Apr 23, 2025

Changeset File Check ✅

  • No modified packages are missing from the changeset file.
  • No changeset formatting errors detected.

@avolkovi avolkovi changed the title Fix Auth Redirects on Firebase Studio Add support for running in Cloud Workstation Apr 24, 2025
@avolkovi avolkovi changed the title Add support for running in Cloud Workstation Add support for emulators running in Cloud Workstation Apr 24, 2025
@avolkovi avolkovi changed the title Add support for emulators running in Cloud Workstation Add support for running the emulators in Cloud Workstation Apr 24, 2025
@google-oss-bot
Copy link
Contributor

google-oss-bot commented Apr 25, 2025

Size Report 1

Affected Products

  • @firebase/auth

    TypeBase (ea1f913)Merge (94b2ce1)Diff
    browser193 kB193 kB+121 B (+0.1%)
    cordova166 kB166 kB+121 B (+0.1%)
    main147 kB147 kB+107 B (+0.1%)
    module193 kB193 kB+121 B (+0.1%)
    react-native165 kB165 kB+107 B (+0.1%)
  • @firebase/auth-cordova

    TypeBase (ea1f913)Merge (94b2ce1)Diff
    browser166 kB166 kB+121 B (+0.1%)
    module166 kB166 kB+121 B (+0.1%)
  • @firebase/auth-web-extension

    TypeBase (ea1f913)Merge (94b2ce1)Diff
    browser142 kB142 kB+121 B (+0.1%)
    main159 kB159 kB+109 B (+0.1%)
    module142 kB142 kB+121 B (+0.1%)
  • @firebase/auth/internal

    TypeBase (ea1f913)Merge (94b2ce1)Diff
    browser204 kB204 kB+121 B (+0.1%)
    main173 kB174 kB+109 B (+0.1%)
    module204 kB204 kB+121 B (+0.1%)
  • @firebase/data-connect

    TypeBase (ea1f913)Merge (94b2ce1)Diff
    browser21.4 kB21.6 kB+185 B (+0.9%)
    main23.7 kB23.8 kB+171 B (+0.7%)
    module21.4 kB21.6 kB+185 B (+0.9%)
  • @firebase/firestore

    TypeBase (ea1f913)Merge (94b2ce1)Diff
    browser384 kB384 kB+179 B (+0.0%)
    main594 kB594 kB+136 B (+0.0%)
    module384 kB384 kB+179 B (+0.0%)
    react-native384 kB385 kB+179 B (+0.0%)
  • @firebase/firestore-lite

    TypeBase (ea1f913)Merge (94b2ce1)Diff
    browser114 kB114 kB+218 B (+0.2%)
    main157 kB157 kB+375 B (+0.2%)
    module114 kB114 kB+218 B (+0.2%)
    react-native114 kB114 kB+218 B (+0.2%)
  • @firebase/storage

    TypeBase (ea1f913)Merge (94b2ce1)Diff
    browser58.0 kB58.4 kB+324 B (+0.6%)
    main59.4 kB59.9 kB+481 B (+0.8%)
    module58.0 kB58.4 kB+324 B (+0.6%)
  • bundle

    29 size changes

    TypeBase (ea1f913)Merge (94b2ce1)Diff
    auth (Anonymous)77.7 kB77.8 kB+132 B (+0.2%)
    auth (EmailAndPassword)87.8 kB87.9 kB+131 B (+0.1%)
    auth (GoogleFBTwitterGitHubPopup)105 kB105 kB+132 B (+0.1%)
    auth (GooglePopup)102 kB102 kB+131 B (+0.1%)
    auth (GoogleRedirect)102 kB102 kB+131 B (+0.1%)
    auth (Phone)95.2 kB95.3 kB+132 B (+0.1%)
    firestore (CSI Auto Indexing Disable and Delete)274 kB275 kB+162 B (+0.1%)
    firestore (CSI Auto Indexing Enable)274 kB275 kB+162 B (+0.1%)
    firestore (Persistence)306 kB306 kB+162 B (+0.1%)
    firestore (Query Cursors)251 kB252 kB+162 B (+0.1%)
    firestore (Query)249 kB249 kB+162 B (+0.1%)
    firestore (Read data once)237 kB237 kB+162 B (+0.1%)
    firestore (Read Write w Persistence)330 kB331 kB+162 B (+0.0%)
    firestore (Realtime updates)239 kB239 kB+162 B (+0.1%)
    firestore (Transaction)216 kB216 kB+162 B (+0.1%)
    firestore (Write data)216 kB216 kB+162 B (+0.1%)
    firestore-lite (Query Cursors)105 kB105 kB+201 B (+0.2%)
    firestore-lite (Query)101 kB101 kB+201 B (+0.2%)
    firestore-lite (Read data once)76.0 kB76.2 kB+201 B (+0.3%)
    firestore-lite (Transaction)101 kB102 kB+201 B (+0.2%)
    firestore-lite (Write data)85.6 kB85.8 kB+201 B (+0.2%)
    storage (getBytes)42.5 kB42.7 kB+185 B (+0.4%)
    storage (getDownloadURL)44.6 kB44.8 kB+185 B (+0.4%)
    storage (getMetadata)44.0 kB44.2 kB+185 B (+0.4%)
    storage (list + listAll)43.5 kB43.6 kB+185 B (+0.4%)
    storage (updateMetadata)44.3 kB44.5 kB+185 B (+0.4%)
    storage (uploadBytes)49.2 kB49.3 kB+185 B (+0.4%)
    storage (uploadBytesResumable)59.1 kB59.3 kB+185 B (+0.3%)
    storage (uploadString)49.4 kB49.5 kB+185 B (+0.4%)

  • firebase

    11 size changes

    TypeBase (ea1f913)Merge (94b2ce1)Diff
    firebase-auth-compat.js141 kB141 kB+102 B (+0.1%)
    firebase-auth-cordova.js138 kB138 kB+144 B (+0.1%)
    firebase-auth-web-extension.js120 kB121 kB+144 B (+0.1%)
    firebase-auth.js158 kB158 kB+144 B (+0.1%)
    firebase-compat.js797 kB797 kB+403 B (+0.1%)
    firebase-data-connect.js17.9 kB18.1 kB+150 B (+0.8%)
    firebase-firestore-compat.js342 kB342 kB+186 B (+0.1%)
    firebase-firestore-lite.js132 kB133 kB+236 B (+0.2%)
    firebase-firestore.js443 kB443 kB+197 B (+0.0%)
    firebase-storage-compat.js39.8 kB40.0 kB+202 B (+0.5%)
    firebase-storage.js46.4 kB46.6 kB+206 B (+0.4%)

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/zf9m0mPBig.html

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Apr 25, 2025

Size Analysis Report 1

This report is too large (238,599 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

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/0ZCHwi5ZbV.html

Copy link
Contributor

Vertex AI Mock Responses Check ⚠️

A newer major version of the mock responses for Vertex AI unit tests is available. update_vertexai_responses.sh should be updated to clone the latest version of the responses: v11.0

@maneesht maneesht marked this pull request as ready for review April 29, 2025 22:16
Copy link
Contributor

@MarkDuckworth MarkDuckworth left a comment

Choose a reason for hiding this comment

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

Approving with knowledge of the time constraints.

If time allowed, I would consider a more generalized solution where the connection class isn't concerned with special behaviors for certain URLs. Rather it could be parameterized to send this browser managed auth with a flag.

And at a higher level, I'm not sure if this will also be useful to external customers. If so, it could be exposed as a public setting. But that may be a future config, like the discussed SSL option for connectXyzEmulator(...).

If this work needs to be deferred, I'm okay with that too.

return this.performRPCRequest<Req, Resp>(rpcName, url, headers, req).then(
const { host } = new URL(url);
const forwardCredentials =
isCloudWorkstation(host) && this.databaseInfo.isUsingEmulator;
Copy link
Contributor

@MarkDuckworth MarkDuckworth Apr 30, 2025

Choose a reason for hiding this comment

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

I'm wondering if you need && this.databaseInfo.isUsingEmulator?

Would it be acceptable to only check for isCloudWorkstation(host)?

I'm concerned that a user could connect to the emulator without calling connectFirestoreEmulator(...), simply by using FirestoreSettings. initializeFirestore(app, { host: cloudWorkstationUrl, ssl: true, port: 443 }). Using that path, it appears that isUsingEmulator would be set to false.

And it may be the agent that attempts to connect that way, not be a developer choice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants