firebase / firebase/firebase-admin-node

[FR] Connect admin-sdk inside functions emulator to multiple different Firebase Projects Emulator instances (Auth,Firestore,..)

未关闭
#2,226 1 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
type: feature request
主要语言
TypeScript
星标
1.7k
派生
419
平均合并
3 天 10 小时
30 天内合并 PR
16

描述

- I have multiple Firebase Projects
- One should be a central "Auth-Provider-Project" which creates custom auth tokens in Firebase Functions for multiple different Firebase Projects

Usually i can initialize multiple different admin apps like so:

```
const authProviderProject = admin.initializeApp(
{ credential: admin.credential.cert(authProviderProjectCred), },
"appOne"
);

const appTwo = admin.initializeApp(
{ credential: admin.credential.cert(appTwoCred), },
"appTwo"
);
```
In this way my locally run admin-sdk (inside the functions emulator) connects to the remote Firebase projects.
The problem now occurs when I also want to emulate Auth, and Firestores locally in the dev/emulator environment. I have to run another set of emulators for each project (next to the authProviderProject which owns the functions using the admin-sdk), but now i can't link my Auth Project Emulators and therefore cant initialize the admin-sdk-apps for my other Projects.
I believe this might be because my functions emulator sets this ENV_VAR:
`export FIREBASE_AUTH_EMULATOR_HOST="127.0.0.1:9099"
`
So i guess i would need a way to point different app initializations to different emulator ports?

I have also tried to initialize the app with the 'projectId' field, but this didn't connect to the correct emulator running on a different port than stated in the FIREBASE_AUTH_EMULATOR_HOST variable.
```
const appTwo = admin.initializeApp(
{ credential: admin.credential.cert(appTwoCred), projectId: "firebaseProjectTwoId" },

"appTwo"
);
```
like stated [here](https://firebase.google.com/docs/emulator-suite/connect_auth#admin_sdks)

Is there a way I can connect multiple locally run emulator suites (multiple Firebase Projects) to the same locally run functions emulator?

贡献指南

打开贡献指南

调研方向

首先检查 admin.initializeApp 以及 issue 中描述的 FIREBASE_AUTH_EMULATOR_HOST 行为,然后跟踪每个 app 如何选择 Auth 和 Firestore emulator 连接。完成的标准是:一个 functions emulator 可以将不同的已初始化 app 连接到彼此独立的本地 Firebase Project emulator 实例,并通过测试或记录的限制覆盖相关配置。

由索引模型根据 Issue 内容生成。

评估

技术栈
node.js, typescript
领域
authentication, backend, databases
Issue 类型
功能
难度
5/5
预计耗时
一周以上
活跃度
停滞
描述清晰度
基本清楚
新手友好度
25/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。