Skip to content

js: switch Firebase auth to bring-your-own project setup#409

Merged
jpcottin merged 1 commit into
google:masterfrom
jpcottin:chore/firebase-byo-config
May 16, 2026
Merged

js: switch Firebase auth to bring-your-own project setup#409
jpcottin merged 1 commit into
google:masterfrom
jpcottin:chore/firebase-byo-config

Conversation

@jpcottin
Copy link
Copy Markdown
Collaborator

Why

js/firebase_config.json ships values for android-emulator-webrtc-demo, a Firebase project nobody on the current team has access to. The Firebase sign-in path has therefore been broken-by-default for some time — explicitly flagged in 5197542 ("Envoy not recognizing Firebase tokens"). Re-pointing at another shared project would inherit the same long-term abandonment risk, so this PR restructures the demo so each contributor configures their own Firebase project.

The self-hosted JWT path (js/jwt-provider/ + js/docker/) is untouched and remains the recommended production setup; this PR only addresses the Firebase quick-start.

What changes

File Change
js/firebase_config.json Deleted. Replaced by firebase_config.example.json (template with placeholders). Real file is gitignored.
js/firebase_config.example.json New — placeholder template users copy + fill in.
js/develop/envoy.yamldevelop/envoy.template.yaml Renamed; project ID literal swapped for __FIREBASE_PROJECT_ID__ sentinel. Rendered output is gitignored.
js/docker/envoy.yamldocker/envoy.template.yaml Same.
js/config_gen.py Rewritten. Fixes a latent no-op bug (txt.replace(search, replace) returned a new string but wasn't reassigned — the in-place envoy substitution silently did nothing for anyone who ran it). New version renders templates → outputs, rejects placeholder values with a helpful error.
js/src/components/login_firebase.js Added a fail-fast check so an unconfigured setup throws an actionable error at module load instead of a cryptic Firebase auth error after a user click.
js/.gitignore Adds firebase_config.json, develop/envoy.yaml, docker/envoy.yaml (all now per-contributor generated artifacts). src/config.js was already ignored.
js/README.md New "Authentication" section documents the two auth backends (self-hosted JWT vs Firebase BYO) and walks through the Firebase setup step-by-step.

Setup (post-merge, for any future contributor)

cd js
cp firebase_config.example.json firebase_config.json
# edit firebase_config.json with values from your Firebase project's web app config
python3 config_gen.py firebase_config.json
# generates src/config.js, develop/envoy.yaml, docker/envoy.yaml (all gitignored)
./develop.sh   # or make develop

Full walkthrough including Firebase console steps is in the updated js/README.md.

Test plan

Verified locally against a Firebase project I own (this PR happens to land on top of the v11 SDK migration #408, so it inherits that fix automatically):

  • config_gen.py firebase_config.example.json exits non-zero with the helpful "placeholder values" error
  • config_gen.py firebase_config.json (with real values) writes 3 files quietly
  • Generated develop/envoy.yaml is byte-identical to the previous committed file modulo the project ID substitution (diff shows zero output against git show upstream/master:js/develop/envoy.yaml | sed s/.../...)
  • Generated docker/envoy.yaml — same
  • git status is clean after running config_gen.py (all generated files gitignored)
  • React app boots, login_firebase.js fail-fast permits valid config
  • Google sign-in popup, ID token retrieved, pushed to TokenProviderService
  • Envoy validates Firebase JWT, proxies gRPC-Web to emulator
  • WebRTC video stream renders in browser

Notes for reviewers

  • The .template.yaml files diverge from upstream's .yaml files only by the project ID literal (android-emulator-webrtc-demo__FIREBASE_PROJECT_ID__) — see the rename diff in the file tree (97% similarity, both files).
  • js/firebase_config.json was the only deleted file. Removing it doesn't break any committed reference — config_gen.py is the only consumer and now generates from .example.json -> user-supplied firebase_config.json.
  • Firebase web API keys are public identifiers (see Firebase docs) — what makes BYO right here is ownership/quota/PII, not secrecy.

The bundled firebase_config.json pointed at android-emulator-webrtc-demo,
a Firebase project that nobody on the current team has access to. The
Firebase sign-in path was therefore broken-by-default for anyone
cloning the repo (flagged previously in 5197542 — "Envoy not recognizing
Firebase tokens").

Rather than re-point at another shared project (which would inherit the
same long-term abandonment risk and require a long-term owner),
restructure the demo so each contributor configures their own Firebase
project:

- Replace firebase_config.json with firebase_config.example.json. The
  real file is gitignored; users copy + fill in values from their own
  Firebase web app config.
- Convert develop/envoy.yaml and docker/envoy.yaml to .template.yaml
  with a __FIREBASE_PROJECT_ID__ sentinel. The rendered .yaml files are
  gitignored.
- Fix the no-op str.replace() bug in config_gen.py — the return value
  was discarded, so the in-place envoy.yaml substitution silently did
  nothing for every contributor who ran the script. Rewrite around a
  clear template -> output render pattern, with input validation that
  rejects placeholder values.
- Add a fail-fast check in login_firebase.js so an unconfigured setup
  produces an actionable error at module load instead of a cryptic
  Firebase SDK auth error after a user click.
- Document the two auth paths in README.md: self-hosted JWT
  (jwt-provider/) as the recommended deployment path, Firebase as a
  quick-start demo with a step-by-step BYO walkthrough.

The self-hosted JWT path (js/jwt-provider/ + js/docker/) is unchanged
and remains the production-grade option that doesn't depend on any
external identity provider.

Verified end-to-end against a Firebase project I own: config_gen.py
generates an envoy.yaml byte-identical to the previous committed file
(modulo the project ID substitution), the fail-fast permits valid
configs and rejects the placeholder template, and the full sign-in ->
gRPC -> WebRTC video flow still works.
@jpcottin jpcottin merged commit faa139d into google:master May 16, 2026
6 checks passed
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.

1 participant