将 firebase 与第三方 JWT 令牌一起使用

Use firebase with a third party JWT token

我想使用第三方 JWT 令牌(来自我当前的身份验证系统),基于此 JWT 令牌生成自定义 firebase 令牌并使用它来访问 firestore 数据库。

我的概念如下:

  1. 应用程序在启动时连接到第三方后端以使用 email/password 进行身份验证 -> 接收 JWT 令牌
  2. 应用使用此第三方令牌调用自己的 firebase 函数
  3. Firebase 函数使用我的第三方后端的 public 密钥验证令牌
  4. Return 由 admin-sdk 创建的新自定义 firebase 令牌
  5. 应用使用这个新的自定义令牌连接到 firebase

我想更好的方法是从我的第三方后端(使用 admin-sdk 生成)发出(第二个)令牌,但我无法真正访问该第三方后端。

这条路适合我吗?或者是否有任何其他基于我的设置的选项?

Firebase 实际上对Authenticating with Firebase in JavaScript Using a Custom Authentication System which is what you are planning to do. You verify that third party token and then create a custom token using signInWithCustomToken() 有详细的解释。然后,您可以 signInWithCustomToken() 并使用 Firebase 安全规则和 Firebase 身份验证等功能。