auth export masks secrets by default with no warning; consumers fail later with invalid_client

未关闭 适合新手
#983 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 1 天内回复

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
64/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
rust
领域
cli, security

调研方向

从 gws auth export 背后的 Rust auth 命令模块开始,找到 --unmasked 标志决定在打印前是否对 client_secret 进行遮蔽的位置;那个分支就是应该放置 stderr 警告或 _masked 标记的地方。结合 README 的 headless/CI 部分阅读导出路径,使警告与文档化的工作流一致,然后检查 auth export 现有的 CLI 测试,添加一个断言被遮蔽输出会发出警告的用例。完成意味着被遮蔽的导出可区分(stderr 警告或标记),而 --unmasked 的输出保持静默;auth status --format json 的小问题则是同一命令树中另一个更小的独立改动。

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

描述

Summary

gws auth export without --unmasked prints credential-shaped JSON and exits 0, with nothing in the output, the exit code, or stderr indicating that the client_secret is masked. Anything that consumes that output — a script, an agent, a human setting up a headless box — accepts the shape and then fails later, inside a different library, with an error that points at credential corruption instead of at the export step.

Environment

  • gws 0.22.5 on Linux
  • OAuth2 desktop client, keyring backend, encrypted credentials store
  • Consumer: google.oauth2.credentials.Credentials.from_authorized_user_info(...) from google-auth

Reproduction

  1. gws auth login interactively; confirm gws auth status reports token_valid: true and that real API calls succeed (they did — gmail users getProfile, calendar calendarList list).
  2. gws auth export → prints JSON with keys type, client_id, client_secret, refresh_token. Exit code 0.
  3. Feed that JSON to google-auth and refresh:
RefreshError: ('invalid_client: The provided client secret is invalid.',
               {'error': 'invalid_client',
                'error_description': 'The provided client secret is invalid.'})

I read that as "the stored client secret is corrupt" and went looking for credential damage — while gws itself kept working fine against the same store, which made export look broken rather than under-promising.

The actual answer was in gws auth export --help:

--unmasked  Show secrets without masking

and in the README's Headless / CI flow, which uses gws auth export --unmasked > credentials.json. Masking by default is the right call; failing silently about it is the problem.

Why it matters

  • Masked output is structurally indistinguishable from a real credential file, so consumers cannot detect it.
  • The failure surfaces later, in another process, with a message that misattributes the cause (invalid_client suggests a bad secret for that client_id, not an intentionally masked value).
  • The CLI knows exactly which flag was missing but never says so.

Suggested fixes

Any one of these would have avoided the detour:

  1. When emitting masked output, warn on stderr: warning: client_secret is masked and this output is not usable as credentials — re-run with --unmasked.
  2. Add a marker field to the JSON when masking, e.g. "_masked": true, so consumers can detect it programmatically.
  3. Consider a non-zero exit (or a --force) when masked output is written while stdout is redirected to a file, since that is the exact shape of the documented copy-to-another-machine workflow.

Related nit (same investigation)

gws auth status --format json fails with error: unexpected argument '--format' (exit 3), even though the default auth status output is already JSON. Every other command surface accepts --format, so scripts that pass it uniformly trip over this one subcommand.

主要语言
Rust
星标
32.3k
派生
2k
平均合并
16 小时 3 分钟
30 天内合并 PR
1

环境准备

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

googleworkspace/cli 的其他 Issue

查看 googleworkspace/cli 的全部 Issue

相似的 Issue

更多 Rust Issue

把新 issue 发到你的邮箱

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