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

Abierto Apto para principiantes
#983 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Los mantenedores suelen responder en 1 día

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
64/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Activo
Stack tecnológico
rust
Área
cli, security

Línea de trabajo

Empieza en el módulo de comandos de auth de Rust que está detrás de gws auth export y localiza dónde el flag --unmasked decide si client_secret se enmascara antes de imprimir; esa rama es donde corresponde una advertencia por stderr o una marca _masked. Lee la ruta de exportación junto con la sección headless/CI del README para que la advertencia coincida con el flujo de trabajo documentado, y luego revisa las pruebas CLI existentes para auth export para añadir un caso que verifique que la salida enmascarada advierte. Hecho significa que las exportaciones enmascaradas se distinguen (advertencia por stderr o marca) mientras que la salida de --unmasked permanece silenciosa; la minucia de auth status --format json es un cambio aparte y más pequeño en el mismo árbol de comandos.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
Rust
Estrellas
32.3k
Forks
2k
Merge medio
16 h 3 min
PR fusionados (30 d)
1

Preparar el entorno

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de googleworkspace/cli

Todos los issues de googleworkspace/cli

Issues similares

Más issues de Rust

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.