Skip to content

Add SpacetimeAuth CLI command - #5251

Open
JulienLavocat wants to merge 5 commits into
masterfrom
julien/spacetimeauth-cli
Open

JulienLavocat wants to merge 5 commits into
masterfrom
julien/spacetimeauth-cli

Conversation

@JulienLavocat

@JulienLavocat JulienLavocat commented Jun 8, 2026 •

Copy link
Copy Markdown
Contributor

Description of Changes

Extends our CLI to add a management interface for SpacetimeAuth (spacetime auth)

API and ABI breaking changes

None.

Rollback safety impact

n/a

Expected complexity level and risk

  1. The code is trivial, it's just a matter of defining CLI arguments and converting them to the parameters used by SpacetimeAuth's API.

Testing

Use a throwaway database: these commands overwrite its SpacetimeAuth settings.

Setup

  1. Build the CLI from this branch and use it for the commands below: cargo run -p spacetimedb-cli -- auth … (shown as spacetime auth …).
  2. Run spacetime login if you are not logged in.
  3. Publish a test database to Maincloud, open it on the dashboard, go to SpacetimeAuth and click Use.

Pass the database name (not its identity) as <db>.

Checks

  • Identity provider: spacetime auth idp set <db> github test-id test-secret
    → the dashboard's Identity Providers page shows GitHub enabled with client ID test-id.
  • Project color: spacetime auth config set <db> color.primary '#ff00aa' (keep the quotes)
    → the Settings page shows the new primary color.
  • Private client: spacetime auth client create <db> --name review --private
    → prints the client without its secret, plus a hint. Run the hinted command and check it returns the secret. The client appears on the Clients page.
  • Duplicate name: run the same client create again → 409 Conflict, "already exists".
  • Invalid value: spacetime auth config set <db> color.primary nope → 400 Bad Request with the reason.

Cleanup

spacetime auth client delete <db> --name review
spacetime auth config reset <db>
spacetime auth idp disable <db> github

@JulienLavocat JulienLavocat changed the title Add spacetime auth CLI interface Add SpacetimeAuth CLI command Jun 8, 2026
@JulienLavocat
JulienLavocat force-pushed the julien/spacetimeauth-cli branch 2 times, most recently from 76e69af to 89e6cc4 Compare June 8, 2026 19:58
@JulienLavocat
JulienLavocat force-pushed the julien/spacetimeauth-cli branch 3 times, most recently from ceaf34b to ec430f3 Compare June 26, 2026 15:00
@JulienLavocat
JulienLavocat force-pushed the julien/spacetimeauth-cli branch 6 times, most recently from 06e649c to 13b3da1 Compare August 6, 2026 14:45
@JulienLavocat
JulienLavocat marked this pull request as ready for review August 12, 2026 14:52
@JulienLavocat
JulienLavocat force-pushed the julien/spacetimeauth-cli branch 4 times, most recently from 8c823b0 to f2deada Compare August 14, 2026 14:43
Comment thread .github/CODEOWNERS Outdated

@clockwork-tien clockwork-tien left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have left a comment

Comment thread crates/cli/src/subcommands/auth.rs Outdated
@JulienLavocat
JulienLavocat force-pushed the julien/spacetimeauth-cli branch from 34b8e7f to 5dd34a2 Compare October 8, 2026 15:46
The client subcommands never sent `database`, which the server requires,
so every client request was rejected. They now take a `<database>`
argument and a `--name` option instead of the ambiguous positional name.

- Error instead of panicking when not logged in
- Derive the API URL from DEFAULT_AUTH_HOST (no trailing slash)
- Leave color and favicon validation to the server
- Allow empty values to clear list settings
- Pretty-print responses and collapse the per-command handlers
- Add unit tests; regenerate the CLI reference
- Remove duplicated CODEOWNERS entry
The SpacetimeAuth management API no longer returns client secrets except
from `client get --include-secret`. After `client create --private` and
`client set private true`, print the command that retrieves the secret.
The hint goes to stderr so stdout stays the JSON response.
- `config reset` keeps the display name and Steam settings; it does not
  reset everything.
- `idp set` also enables the provider.
- The database argument is a name; identities are rejected.
- Document comma-separated lists and that an empty value clears them.
Passing the secret as an argument saves it to shell history. The argument is now optional: when omitted, the secret is prompted for with hidden input, or read from stdin when piped.
@JulienLavocat
JulienLavocat force-pushed the julien/spacetimeauth-cli branch from 5dd34a2 to 393dd38 Compare October 14, 2026 10:04

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants