[firebase_auth_web]: Make the Auth emulator persistence from #18926 configurable instead of hard-gated on kDebugMode
维护者通常 4 天内回复
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 62/100
- Issue 类型
- 功能
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
调研方向
Start from the two kDebugMode gates in packages/firebase_auth/firebase_auth_web/lib/firebase_auth_web.dart (restore on plugin init ~L60-75, remember-after-connect ~L565-600) and read the #18926 diff; the isAuthEmulatorDebugHost loopback check stays as is. Because the origin is reapplied inside Firebase.initializeApp, the flag must be readable before init: decide between a static on FirebaseAuth in the firebase_auth package (threaded through the platform interface) or a bool.fromEnvironment define, then have the web implementation read it. Done means the default still equals kDebugMode, profile builds can opt in, and existing web auth tests plus a new gate test pass.
由索引模型根据 Issue 内容生成。
描述
Which plugins/Platforms are affected?
Auth on Web
TL;DR
The fix from #18926 that keeps the Auth emulator across restarts is hard-gated on kDebugMode, so profile builds can't use it; please make that gate a setting, with a default of kDebugMode to keep existing behavior.
Description
#18926 (fixing #18888) keeps the Auth emulator origin across reloads and browser restarts, so a persisted user is never restored against production before useAuthEmulator runs. All of it is hard-gated on kDebugMode:
- restore on plugin init: https://github.com/firebase/flutterfire/blob/6a80b1b5eea1ea86ba8c7e7bf2a8525cabb77126/packages/firebase_auth/firebase_auth_web/lib/firebase_auth_web.dart#L60-L75
- remember after connect: https://github.com/firebase/flutterfire/blob/6a80b1b5eea1ea86ba8c7e7bf2a8525cabb77126/packages/firebase_auth/firebase_auth_web/lib/firebase_auth_web.dart#L565-L600
Request: replace those kDebugMode checks with a single setting whose default is kDebugMode, so nothing changes unless an app opts in. Because the origin is reapplied inside Firebase.initializeApp, the setting has to be readable before init, e.g. either:
// set before Firebase.initializeApp
FirebaseAuth.persistWebEmulatorOrigin = true; // default: kDebugMode
or a compile-time define:
const persist = bool.fromEnvironment(
'FIREBASE_AUTH_PERSIST_EMULATOR',
defaultValue: kDebugMode,
);
The existing loopback-host check (isAuthEmulatorDebugHost) would stay as it is.
Why is this important?
Profile builds are a normal way to test against the emulators. Debug can be too slow for canvas-heavy apps. In profile mode today:
- The persisted (anonymous) emulator user is restored from IndexedDB on startup.
- If its ID token is older than an hour, it is refreshed against
securetoken.googleapis.com, which is production. With a referrer-restricted key, that fails withauth/requests-from-referer-http://localhost:<port>/-are-blocked. - The later
useAuthEmulatorcall fails withemulator-config-failed, silently outside debug, so Auth stays on production for the whole session, and Firestore on its emulator reports "client is offline".
The only way out is clearing site storage, which deletes the anonymous user and its emulator data every time.
Additional context and comments
firebase_core 5.2.0, firebase_auth 7.1.0, firebase_auth_web 6.4.0.
Related: #11233, #11534, #18689, #18888, #18926.
- 主要语言
- Dart
- 星标
- 9.3k
- 派生
- 4.1k
- 平均合并
- 4 天 17 小时
- 30 天内合并 PR
- 49
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
firebase/flutterfire 的其他 Issue
-
[cloud_functions]: Apple platforms ignore custom domains passed as region可能已有人在做 @ragavendranbala-TSL 今天认领。 未关闭Needs Attention platform: ios platform: macos plugin: functions type: bug
难度 2/5 1-3 小时 新手友好度 78/100
firebase/flutterfire#19015 · 2 条评论 ·
维护者通常 4 天内回复
-
Needs Attention platform: android plugin: messaging type: bug
难度 4/5 3-5 天 新手友好度 45/100
firebase/flutterfire#19017 ·
维护者通常 4 天内回复
-
Needs Attention platform: web plugin: crashlytics type: enhancement
难度 5/5 一周以上 新手友好度 34/100
firebase/flutterfire#19014 · 1 条评论 ·
维护者通常 4 天内回复
-
[firebase_messaging]: Android getToken() errors lose their cause since firebase-messaging 25.1.0 ("FCM Registration failed!")可能已有人在做 @SelaseKay 于 3 天前认领。 未关闭Needs Attention platform: android plugin: messaging reproduced type: bug
难度 4/5 3-5 天 新手友好度 22/100
firebase/flutterfire#18997 · 1 条评论 ·
维护者通常 4 天内回复
-
[firebase_storage]: Windows: getData() crashes with access violation (use-after-free of StorageReference in ReferenceGetData)可能已有人在做 @SelaseKay 于 4 天前认领。 未关闭blocked: customer-response platform: windows plugin: storage type: bug type: crash
难度 4/5 3-5 天 新手友好度 35/100
firebase/flutterfire#18994 · 2 条评论 ·
维护者通常 4 天内回复
查看 firebase/flutterfire 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 72/100
hajisensai/Fushi#4543 · 3 条评论 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 62/100
dart-lang/dart_style#1928 ·
-
难度 1/5 1 小时以内 新手友好度 88/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 88/100
chriskelly/wish-together#212 ·
维护者通常 1 天内回复