【问题标题】:Firebase Admin NodeJS SDK: TenantAwareAuth.createSessionCookie() throws unsupported tenant operationFirebase Admin NodeJS SDK:TenantAwareAuth.createSessionCookie() 抛出不受支持的租户操作
【发布时间】:2021-12-18 06:03:03
【问题描述】:

使用 Firebase Admin SDK 实现租户感知身份验证实例时,我无法使用 following method

代码:

    // defined elsewhere: locals.tenantAuth = getAuth().tenantManager().authForTenant(tenantId)

    async createSession (locals) {
    try {
      const { idToken, expiresIn, tenantAuth } = locals
      const decodedToken = await tenantAuth.verifyIdToken(idToken, true) // this works
      // Only process if the user just signed in in the last 3 minutes
      if (new Date().getTime() / 1000 - decodedToken.auth_time < 3 * 60) {
        return await tenantAuth.createSessionCookie(idToken, { expiresIn }) // this breaks
      } else {
        throw new Error('Cannot create session, sign in information is too old')
      }
    } catch (error) {
      console.log(error)
      throw new Error(error)
    }
  }

错误:

FirebaseAuthError: This operation is not supported in a multi-tenant context.
errorInfo: {
  code: 'auth/unsupported-tenant-operation',
  message: 'This operation is not supported in a multi-tenant context.'
},
codePrefix: 'auth'

版本:

  • Nodejs:16.13.0
  • Firebase 管理员 SDK:10.0.0

补充:

  • 方法在tenantAware 身份验证之外工作(使用默认项目getAuth()
  • v9 出现同样的错误

【问题讨论】:

    标签: node.js firebase multi-tenant firebase-admin google-identity


    【解决方案1】:

    这已作为功能请求提交。您可以通过这个提交的feature request link查看它的状态。

    您可能需要检查此Stack Overflow link 作为解决方法。

    【讨论】:

      猜你喜欢
      • 2021-12-23
      • 1970-01-01
      • 1970-01-01
      • 2015-04-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-11-14
      相关资源
      最近更新 更多