Hacktoberfest 2026:維護者為十月標記出來的 issue,仍然開放、適合新手。 瀏覽 Hacktoberfest issue

identity_fn.AuthBlockingEvent is still missing auth_type and resource

未關閉 適合新手
#316 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

還沒有人認領這個 Issue。

評估

難度
2/5
預估耗時
1-3 小時
新手友好度
84/100
Issue 類型
功能
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
python
領域
api

研究方向

從 src/firebase_functions/identity_fn.py 中的 AuthBlockingEvent dataclass 開始,它旁邊是 #231 新增的欄位(event_type、email_type、sms_type)。依照連結的 Node 端 parseAuthEventContext 邏輯推導兩個新屬性:auth_type 根據 user_record 是否存在得出,resource 根據 tenant_id 與專案 ID 得出。完成的標準是重現片段不再拋出 AttributeError,且 identity_fn 的現有測試套件通過,並涵蓋租戶與非租戶兩種情況。

由索引模型根據 Issue 內容生成。

描述

bug
Summary

#231 added event_type, email_type, and sms_type to identity_fn.AuthBlockingEvent (thanks!). Two properties from the blocking functions doc are still missing, so code written from the doc fails on Python:

Doc property Node firebase-functions Python firebase-functions
authType authType: "USER" | "UNAUTHENTICATED" not present
resource resource: { service, name } not present
Repro
from firebase_functions import identity_fn

@identity_fn.before_user_signed_in()
def handle(event: identity_fn.AuthBlockingEvent):
    event.auth_type  # AttributeError
    event.resource   # AttributeError

Checked against the AuthBlockingEvent dataclass on main (identity_fn.py) and in 0.6.0.

Where the values come from

The Node SDK derives both from the blocking token rather than reading dedicated claims, so Python can do the same. From parseAuthEventContext:

  • authType is "USER" when the token has a user_record, otherwise "UNAUTHENTICATED".
  • resource.service is identitytoolkit.googleapis.com, and resource.name is projects/<project-id>/tenants/<tenant_id> when the token has a tenant_id, otherwise projects/<project-id>.
Context

First reported in firebase/functions-samples#1129 and in #224, which #231 partly addressed. I'm closing the samples issue in favor of this one, since the fix belongs in the SDK. Until then, the tenant is available as event.data.tenant_id.

主要語言
Python
星號
167
分支
36
平均合併
4 天 3 小時
30 天內合併 PR
1

環境準備

  • 沒有 Dockerfile 或 Docker Compose 檔案
  • 沒有 Pull Request 範本
  • 閱讀貢獻指南

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

firebase/firebase-functions-python 的其他 Issue

查看 firebase/firebase-functions-python 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。