C12.4: mail credentials and OAuth sign-in

Passwords and refresh tokens go only to the system keychain; a refused
keychain keeps them in memory until exit and says why. Gmail and
Microsoft sign in by authorization code with S256 PKCE on a loopback
redirect; refresh tokens are kept, and revoked grants ask to sign in
again. Client IDs come from the build (env or oauth.env). ureq trace
records never reach the log.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
ZacharyZhang-NYandClaude committed 2026-10-19 18:59:56 -04:00
1 parent 7c5bf48589
commit bd68382921
19 files changed
+1065 -6

No files matched your search

+9
View File
@@ -0,0 +1,9 @@
FAIL
- crates/ely-mail-engine/src/oauth.rs:99 — [P1] Google 授权 URL 没有 `access_type=offline`。[Google 文档](https://developers.google.com/identity/openid-connect/openid-connect#refresh-tokens)规定,请求离线访问才会在换码时取得刷新令牌。首次添加 Gmail 时,即使用户授权成功,也可能只得到短期 access token;到期或重启后无法完成 C12.4 要求的刷新。隔离探针调用实际 `google()` 和 `SignIn::start`,断言该参数时得到 `None`(`.work/C12.4-r1/linux-probes.log`);现有测试的自定义 provider 掩盖了这个缺口。修复方向:Google 授权请求加入离线访问参数,并测试内置 provider 的授权参数与刷新令牌签发条件。
- crates/ely-mail-engine/src/oauth.rs:60 — [P2] Microsoft scope 缺少 `profile`,但邮箱读取依赖 `preferred_username` 作为 `email` 缺失时的回退。[Microsoft 文档](https://learn.microsoft.com/en-us/entra/identity-platform/id-token-claims-reference)明确该 claim 需要 `profile` scope。因此,未提供 `email` claim 的账号完成授权后,也拿不到承诺的回退值,`Tokens.email` 仍为空。实际 `microsoft()` 的参数探针确认没有申请此 scope(`.work/C12.4-r1/linux-probes.log`)。修复方向:申请该 claim 所需的 scope,补测 Microsoft 无 email、使用 preferred_username 的路径。
- crates/ely-mail-engine/build.rs:16 — [P2] `read_to_string` 的所有错误都直接返回,文件不存在与文件损坏、无法读取被混为一谈。复现:隔离编译原始 build.rs,让其读取含无效 UTF-8 的 `oauth.env`,退出码仍为 0,且没有配置错误提示(`.work/C12.4-r1/config-invalid-utf8.log`)。正常没有环境变量的本机构建会悄悄忽略已有配置,把登录变为 `Unavailable`,违反错误必须暴露与坏配置构建失败的要求。修复方向:只允许 NotFound 表示未配置,其余读取错误使构建失败并说明原因,补测损坏与不可读文件。
- crates/ely-mail-engine/src/oauth/loopback.rs:14 — [P3] 新增注释 `Serves the redirect until it carries a code or an error.` 共 11 词,超过 agents.md 的十词限制;运行项目 `tests/scripts/comments.py` 可复现该行失败。修复方向:缩短到十词以内。
+3
View File
@@ -0,0 +1,3 @@
FAIL
- crates/ely-mail-engine/src/oauth/token.rs:81 — [P1] 读取令牌回复时,ureq-proto 会在 trace 级别逐字节记录整个 JSON,访问令牌与刷新令牌因此进入普通诊断日志,违反 §18.2 与 agents.md 的日志规则。复现:以 `ELY_LOG=trace` 初始化真实的 `ely_platform::logging`,调用实际 `oauth::refresh`,替身端点返回 `ACCESSMARKER` 与 `ROTATEDMARKER`;两者均出现在 `ely.log`(`.work/C12.4-r2/oauth-logger/ely.log`,核对输出在 `actual-logger.log`)。换码同样经过此读取路径;现有日志隐私测试只跑邮件协议,没有覆盖 OAuth,所以 Windows 97 个、Linux 94 个测试全部通过仍未发现泄漏。修复方向:阻止 HTTP 库在任何日志级别记录令牌回复的敏感载荷,并以真实日志器补测换码与刷新的令牌不进入日志。
+1
View File
@@ -0,0 +1 @@
PASS