firebase / firebase/firebase-admin-node

Cloud Run (Firebase Functions Gen2) returns Firestore PERMISSION_DENIED despite roles/datastore.user on service account

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

描述

I am running a backend for an Android app using Firebase Functions Gen2 (Cloud Run).
The backend exposes an HTTP endpoint and uses the Firebase Admin SDK to write to Firestore.

The endpoint is reachable and processes requests, but every Firestore write fails with:

PERMISSION_DENIED: Missing or insufficient permissions

This happens consistently and results in HTTP 500 responses.

Environment

Firebase Functions Gen2 (running on Cloud Run)

Firebase Admin SDK (Node.js)

Firestore (Native mode)

Android client calling the HTTP endpoint

No client-side Firestore access involved

Expected behavior

Firestore writes via Admin SDK should succeed when the runtime service account has the required IAM role.

Actual behavior

HTTP request reaches the Cloud Run service

Business logic executes

Firestore write fails with PERMISSION_DENIED

Error persists even after redeploying the service

What I have already verified

Firestore security rules are not the cause (Admin SDK is used)

IAM role roles/datastore.user has been granted to:

App Engine default service account

A dedicated custom service account

Service was redeployed after IAM changes

No hardcoded credentials or service account keys are used

Despite this, Firestore access is still denied.

Questions

Which service account is actually used at runtime by Firebase Functions Gen2 / Cloud Run?

Is the Compute Engine default service account used by default unless explicitly overridden?

Is it considered best practice to explicitly set a runtime service account for Cloud Run when using Firestore?

Are there known cases where the Admin SDK still fails with PERMISSION_DENIED due to IAM misconfiguration in Cloud Run Gen2?

Any clarification or guidance would be highly appreciated.

贡献指南

打开贡献指南

调研方向

从 HTTP 端点的 Firebase Admin SDK Firestore 写入路径以及 Firebase Functions Gen2/Cloud Run 运行时配置入手。验证运行时使用的是哪个服务账号,并将其与问题单中列出的账号进行比较。完成标准是确定负责的配置,并记录或复现写入路径预期的 IAM 行为。

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

评估

技术栈
node.js
领域
backend, cloud, databases
Issue 类型
缺陷
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
需要澄清
新手友好度
25/100

把新 issue 发到你的邮箱

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