使用 Firebase Admin SDK 實作租戶感知身份驗證實體時,我無法使用以下方法。
代碼:
// 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'
版本:
- 節點:16.13.0
- Firebase 管理 SDK:10.0.0
額外的:
- 方法在tenantAware auth之外作業(使用默認專案
getAuth()) - v9 上同樣的錯誤
uj5u.com熱心網友回復:
這已作為功能請求提交。您可以通過此提交的功能請求鏈接查看其狀態。
您可能需要檢查此堆疊溢位鏈接作為解決方法。
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/349408.html
標籤:节点.js 火力基地 多租户 firebase-admin 谷歌身份
