Skip to content

fix: derive faas auth token fallback & mirror temp api token helper - #923

Open
AlexCXC wants to merge 2 commits into
masterfrom
opt-temp-api-token
Open

AlexCXC wants to merge 2 commits into
masterfrom
opt-temp-api-token

Conversation

@AlexCXC

@AlexCXC AlexCXC commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

Same PyJWT 2.x empty-HMAC-key fix as dtable-web: derive a stable 'faas-auth:' + JWT_PRIVATE_KEY fallback when SEATABLE_FAAS_AUTH_TOKEN is empty, and extract gen_dtable_temp_api_token so general_actions' run-python-script keeps generating valid temp tokens.

@seafile-dev seafile-dev left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

结论:请求修改。

阻塞问题:dtable_events/app/config.py:99–100 的回退覆盖了同时用于 HTTP 鉴权的 SEATABLE_FAAS_AUTH_TOKEN。空配置时,run_script 等调用会将 faas-auth:+JWT_PRIVATE_KEY 原文发送到请求头,接收方可还原主 JWT 密钥;python-pipeline 当前 main 仍按原 PYTHON_SCHEDULER_AUTH_TOKEN 校验,回退后的请求也会被拒绝。

这是三个配套 PR 的同一根因,统一行内意见位于 https://github.com/seafileltd/dtable-web/pull/6408#discussion_r4469718955 ,此处不重复创建行内线程。

建议修复:保留原 scheduler HTTP 鉴权配置,另设三服务一致的临时 JWT 签名密钥,空配置时采用带用途标签的 HMAC/HKDF 派生值;不要直接拼接主密钥,也不要使用公开固定签名密钥。

验证:当前 head 的原始生产函数体隔离执行表明,显式配置保留、生成的临时 token 可被配套 Web 验签;真实回环 HTTP 接收器收到含主密钥的请求头,恢复的测试密钥可生成通过 Web 生产 Base token 认证方法的凭据。对 scheduler 实际 check_auth_token 函数的协议检查确认空配置失配;这些检查不是完整服务/数据库或线上集成测试。

CI:已读取当前 head 的 Actions 作业日志,SQL 测试 6 个、webhook 测试 16 个通过;该 runner 不包含这次签名回退的专门回归。建议增加空/显式配置、跨服务签验和请求头不得包含主密钥的回归测试。

已分析问题文档:https://dev.seafile.com/seahub/smart-link/c48007d1-26a6-473e-85a2-a193799527d8/ 。文档应明确区分临时签名和服务鉴权,避免将固定 faas-auth: 作为公开签名密钥。

@seafile-dev seafile-dev left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

结论:批准本仓库当前改动,替代此前针对签名回退的请求修改结论。
审查 head:6497e804095b1189baf09ae143a293138e26662e。

原阻塞已不适用:真实配置加载不再拼接主 JWT 密钥,空/缺失 token 生成入口明确抛错;显式配置保留,HTTP 继续使用原 scheduler 鉴权值。三服务统一问题原线程已更新:https://github.com/seafileltd/dtable-web/pull/6408#discussion_r4469718955 。

验证:本仓库 34 项 exact-source 隔离检查通过,覆盖空/显式配置、真实 PyJWT 跨 Web 签验、过期/篡改拒绝、用户/组织 action 的回环 HTTP 发送及错误处理;空配置在提交脚本前失败。应用初始化、ORM/RPC和接收方被替代,不代表完整服务/线上集成。当前 head Actions 成功,日志 SQL 6 + webhook 16 通过,但不覆盖新增 token helper。

符合当前设计不提供回退的约束:https://dev.seafile.com/seahub/smart-link/e77b80c9-0f92-4ed9-b418-973412b0dd3b/ 。建议同步修改仍描述 fallback 的 PR 标题/说明并加入专门回归测试。

此批准仅限本仓库/head,不表示整个任务可发布:Web 的 scoped JWT 资源范围问题及 SDK 的资产认证、Socket.IO 刷新问题仍阻塞整体验收。必须先完成服务端兼容,再迁移 SDK;仍使用 Python runner 时继续保持四服务一致的显式 token。

Same PyJWT 2.x empty-HMAC-key fix as dtable-web: derive a stable 'faas-auth:' + JWT_PRIVATE_KEY fallback when SEATABLE_FAAS_AUTH_TOKEN is empty, and extract gen_dtable_temp_api_token so general_actions' run-python-script keeps generating valid temp tokens.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants