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 摘要。