feat(cli): token env vars for CI/CD auth#1876
Draft
dawsontoth wants to merge 2 commits into
Draft
Conversation
`harper login` now offers a copy-paste CI/CD credential block (target + long-lived refresh token) after an interactive login, and the CLI's Bearer-token path reads HARPER_CLI_OPERATION_TOKEN / HARPER_CLI_REFRESH_TOKEN (with CLI_TARGET_* aliases) so `harper deploy` and other remote operations can authenticate in CI without a stored password or a prior `harper login`. Env-var tokens take precedence over ~/.harperdb/credentials.json and are used in-memory only (never persisted). A refresh token alone is sufficient: when no operation token is supplied (or it's expired), the CLI mints a fresh one from the refresh token on each run — the single durable secret CI needs. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Code Review
This pull request introduces support for environment-variable-based bearer token authentication in the CLI, which is particularly useful for CI/CD environments. It allows the CLI to use HARPER_CLI_OPERATION_TOKEN and HARPER_CLI_REFRESH_TOKEN (and their aliases) to authenticate, bypassing or overriding the local credentials file. Additionally, the interactive login flow now prompts users to print these environment variables for easy setup in CI/CD pipelines. Unit tests have been added to verify these authentication flows and the environment variable output. I have no feedback to provide as there are no review comments to assess.
Contributor
|
Reviewed; no blockers found. |
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
Summary
Two small additions that give a clean local-login → CI/CD path so Harper credentials don't have to live in the wild:
harper logincan emit a copy-paste CI/CD credential block. After a successful interactive login it asks (default No): "Print environment variables so CI/CD can deploy without your password?" On yes it prints the target and the long-lived refresh token, ready to paste into GitHub Actions (or other) repository secrets:The prompt is skipped when stdin isn't a TTY (e.g. a scripted/CI login driven by
HARPER_CLI_PASSWORD), so it never blocks or dumps tokens into non-interactive output.The CLI's Bearer-token path reads tokens from env vars.
harper deployand other remote operations now honorHARPER_CLI_OPERATION_TOKEN/HARPER_CLI_REFRESH_TOKEN(withCLI_TARGET_*aliases), so a runner can authenticate without a stored password or a priorharper login.Behavior
~/.harperdb/credentials.json(unchanged).HARPER_CLI_TARGET+HARPER_CLI_REFRESH_TOKENas durable secrets.Tests
unitTests/bin/login.test.js(opt-in prints target + refresh token only; decline prints nothing) andunitTests/bin/cliOperations.test.js(env token overrides file creds; refresh-token-only minting; expired-token refresh without persisting;CLI_TARGET_*alias).binlogin/cliOperations suites pass;oxlintclean.Follow-up
HarperFast/documentation(new env vars + a GitHub Actions example) — not included here.🤖 Generated with Claude Code