Skip to content

Add signadot auth token command - #301

Merged
foxish merged 4 commits into
mainfrom
auth-token-stdout
Feb 27, 2026
Merged

foxish merged 4 commits into
mainfrom
auth-token-stdout

Conversation

@scott-cotton

@scott-cotton scott-cotton commented Feb 27, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Adds `signadot auth token` subcommand that prints the bearer token to stdout (no newline) for scripting and piping
  • Returns the cached token if still valid; refreshes transparently via the existing `checkKeyringAuth` flow only when expired
  • Errors with a clear message when using API key auth (no bearer token involved)
  • Errors when not authenticated

Test plan

  • `signadot auth token` prints a valid bearer token after `signadot auth login`
  • `signadot auth token` returns the cached token without a network call when not expired
  • `signadot auth token` refreshes automatically when the token is expired (requires an expired token to exercise)
  • `signadot auth token` errors when not authenticated (requires logging out of keyring)
  • `signadot auth token` errors with a helpful message when using API key auth
  • Output has no trailing newline (`signadot auth token | wc -c`)

🤖 Generated with Claude Code

scott-cotton and others added 2 commits February 27, 2026 13:19
Add RefreshBearerToken() to API config that always calls the refresh
endpoint, and use it in the token command instead of InitAPIConfig().

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Comment thread internal/config/api.go Outdated
return nil
}

// RefreshBearerToken forces a token refresh using the stored refresh token,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This will invalidate the previous token when called which gives me pause. Isn't it better to just invalidate if it's close to expiry anyway how the rest of the refresh mechanic works?

foxish and others added 2 commits February 27, 2026 09:28
Replace force-refresh with lazy refresh: return the cached token if still
valid, refresh via InitAPIConfig (which uses the existing checkKeyringAuth
flow) only when expired, and error if authenticated with an API key.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

@foxish foxish left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@foxish
foxish merged commit e253a00 into main Feb 27, 2026
@foxish
foxish deleted the auth-token-stdout branch February 27, 2026 17:34
@joehorsnell

Copy link
Copy Markdown
Contributor

Thanks for implementing this feature @scott-cotton and @foxish!

Just one question, out of interest - are there any tests for this CLI functionality? I was expecting to see some CLI tests to invoke the new command, check the token generation, etc.?

@scott-cotton

Copy link
Copy Markdown
Member Author

Thanks for implementing this feature @scott-cotton and @foxish!

Just one question, out of interest - are there any tests for this CLI functionality? I was expecting to see some CLI tests to invoke the new command, check the token generation, etc.?

We tested this one manually. Testing with auth is harder to automate and these changes largely rely on calls to existing functions. We may add tests to our internal e2e suite exercising this, as it already needs to setup auth automation. Since folks are waiting on this and we don't need to automate the tests to validate it, we've not prioritised that yet.

@joehorsnell

Copy link
Copy Markdown
Contributor

Related - I noticed that the Signadot CLI auth docs had not been updated, so created an issue to suggest adding some @scott-cotton.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants