feat(cli): add --reveal flag to projects api-keys#5633
Open
Coly010 wants to merge 1 commit into
Open
Conversation
New secret API keys (`sb_secret_...`) are returned redacted by the Management API unless the request carries `reveal=true`, so `supabase projects api-keys` printed `******` for them with no override. This breaks CI/preview-environment flows that scrape keys via `--output json`/`env` to populate service env vars. Add an opt-in `--reveal` boolean flag (native TS legacy shell only) that threads `reveal=true` through the shared fetch helper. Default behavior is unchanged and byte-identical to Go: the query param is omitted entirely when the flag is absent, so `bootstrap` (which only consumes the never-redacted anon key) stays on the default path. Masking is null-based, so revealed keys flow through every output format with no formatter change. Fixes #4775
Supabase CLI previewnpx --yes https://pkg.pr.new/supabase/cli/supabase@f964fc62ba731a938b93bc37b0c405e0f4ed349dPreview package for commit |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
Adds an opt-in
--revealboolean flag tosupabase projects api-keys(native TS legacy shell).When set, the command sends
reveal=truetoGET /v1/projects/{ref}/api-keysso the Management API returns the full secret keys (sb_secret_...) inapi_keyinstead of redacting them tonull. The redacted values then render as******across all output formats. With--reveal, the populatedapi_keyflows through every format (text table,--output json/yaml/toml/env, and the TS--output-format json/stream-jsonenvelope) — no formatter changes were needed since masking is purely null-based.Why
Redaction is server-side: new secret keys come back
nullunless the request carriesreveal=true, and the command never sent it. Users had no way to retrieve secret keys via the CLI, breaking CI/preview-environment flows that scrape keys (e.g.--output json/env) to populate service env vars. The samereveal=truemechanism was already used internally by other flows (link/bootstrap-adjacent) — it just wasn't exposed on this command.Fixes #4775.
Reviewer context
revealquery param is omitted entirely when the flag is absent, keeping the default request byte-identical to the Go CLI.bootstrapis unaffected. It shareslegacyGetProjectApiKeysbut calls it without the flag and only consumes the never-redacted anon key, so it stays on the default path.apps/cli-go) is intentionally not touched; the flag is recorded as a TS-only divergence indocs/go-cli-porting-status.md.--revealis a boolean, so its value is logged verbatim by the instrumentation (consistent with all other boolean flags); the secret key values are never logged, cached, or written to disk.