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

オープン 初心者向け
#983 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
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分
マージ済み PR(30日)
1

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

googleworkspace/cli のほかの issue

googleworkspace/cli の issue をすべて見る

似ている issue

Rust の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。