Skip to content

Document CLI authentication precedence and dedicated credentials - #613

Merged
kriszyp merged 2 commits into
mainfrom
kris/cli-auth-docs-1873
Jul 31, 2026
Merged

Document CLI authentication precedence and dedicated credentials#613
kriszyp merged 2 commits into
mainfrom
kris/cli-auth-docs-1873

Conversation

@kriszyp

@kriszyp kriszyp commented Jul 27, 2026

Copy link
Copy Markdown
Member

Documents the dedicated auth_username=/auth_password= parameters and revised CLI credential precedence from HarperFast/harper#1873, including atomic environment-variable pairs, CI/CD user-management examples, application deployment guidance, and stale-token recovery. Also adds the Harper 5.2 release-note entry and replaces the applications guide's legacy credential example.

Refs HarperFast/harper#1872.

Generated with Codex (GPT-5).

@github-actions

Copy link
Copy Markdown

🚀 Preview Deployment

Your preview deployment is ready!

🔗 Preview URL: https://preview.harper-documentation.harperfabric.com/pr-613

This preview will update automatically when you push new commits.

@github-actions
github-actions Bot temporarily deployed to pr-613 July 27, 2026 19:16 Inactive
@kriszyp
kriszyp marked this pull request as ready for review July 27, 2026 19:16
@kriszyp
kriszyp requested a review from a team as a code owner July 27, 2026 19:16

@gemini-code-assist gemini-code-assist Bot 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.

Code Review

This pull request updates the documentation to reflect the new CLI authentication precedence and dedicated authentication parameters (auth_username and auth_password) introduced in version 5.2.0. This includes updates to the CLI authentication guide, CLI overview, applications component reference, and the v5.2 release notes. There are no review comments, so I have no feedback to provide.

@kriszyp
kriszyp removed the request for review from a team July 27, 2026 19:17
Comment thread reference/cli/authentication.md Outdated
Addresses review feedback from cb1kenobi on PR #613 — items 3 and 4
were bare variable names without stating they're environment variables.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@github-actions
github-actions Bot temporarily deployed to pr-613 July 29, 2026 15:55 Inactive
@github-actions

Copy link
Copy Markdown

🚀 Preview Deployment

Your preview deployment is ready!

🔗 Preview URL: https://preview.harper-documentation.harperfabric.com/pr-613

This preview will update automatically when you push new commits.

@Ethan-Arrowood Ethan-Arrowood 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.

I traced every precedence claim in this page against bin/cliOperations.ts on harper main — the ordering, the pre-5.2 behavior note, the auth_-parameter semantics, and the stale-token troubleshooting are all accurate. Nice page.

One substantive problem, inline: the percent-encoding advice for target-URL credentials describes behavior the CLI doesn't have today, so following it produces auth failures rather than fixing them. That's really an upstream harper bug, not just a docs wording issue — flagging it here because the sentence should either come out or be replaced with a limitation note until harper decodes userinfo.

sent with Claude Opus 5

target=https://username:password@server.example.com:9925
```

Percent-encode reserved characters in either value (`@` becomes `%40`, for example). Avoid this form when possible: the URL can be exposed in shell history and process listings, and `harper login` can save its target to the project `.env` file. Prefer environment variables or a saved login for routine use.

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 advice can't work against current harper main. WHATWG URL getters return userinfo still percent-encodednew URL('https://admin:p%40ss@host').password === 'p%40ss', and a raw @ gets re-encoded the same way — and the CLI feeds parsedTarget.username/password verbatim into the Basic header (cliOperations.ts:399basicAuthHeader) with no decodeURIComponent anywhere; normalizeTarget preserves the encoding too.

So a real password p@ss goes out as p%40ss and authentication fails — encoded or not, the URL form simply can't carry reserved-character passwords right now. I verified the URL behavior with Node directly. harper#1873's tests don't cover encoded userinfo.

Two ways forward: harper decodes userinfo the way curl does (feasible before 5.2 ships), or this sentence is replaced with an explicit limitation note scoping the URL form to reserved-character-free credentials. Either way it shouldn't ship as-is.

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.

Corroborating this — I verified it independently and it holds.

extractTargetCredentials (bin/cliCredentials.ts:28) returns WHATWG URL.username/.password, which stay percent-encoded, and resolveTransportCredentials passes them verbatim to basicAuthHeader with no decodeURIComponent anywhere on the path. Confirmed in Node: new URL('https://admin:p%40ss@host').password === 'p%40ss', and a raw @ re-encodes to the same thing.

So a password of p@ss goes out as the literal p%40ss and 401s — following this advice causes the failure it claims to prevent, and not following it fails too.

Either harper decodes userinfo before 5.2 ships, or the sentence becomes a limitation note scoping the URL form to credentials without reserved characters. I'd block on it not shipping as written rather than on which of the two fixes you pick.


# The environment variables authenticate the admin; username/password remain payload fields.
# NEW_USER_PASSWORD is provided by a secret manager.
harper add_user \

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.

Small hardening thought: the auth credentials here are properly protected, but the new user's password= still lands in argv — "$NEW_USER_PASSWORD" keeps it out of shell history, yet the expanded value is visible in process listings. That's inherent to CLI add_user rather than anything this PR introduces, but since this page is the security guidance, a one-line caveat under these examples would keep it airtight.

@kriszyp
kriszyp merged commit a352139 into main Jul 31, 2026
7 checks passed
@kriszyp
kriszyp deleted the kris/cli-auth-docs-1873 branch July 31, 2026 14:34
@github-actions

Copy link
Copy Markdown

🧹 Preview Cleanup

The preview deployment for this PR has been removed.

@DavidCockerill DavidCockerill 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.

This covers all three things I asked for on harper#1873 and gets them right — I verified the precedence order, the pair-atomicity rule, the pre-5.2 note and the stale-token entry against cliOperations.ts rather than taking the page's word for it. Good, careful doc.

Requesting changes on two things:

  1. @Ethan-Arrowood's percent-encoding thread — I've replied there with an independent confirmation. The URL-credentials advice can't work as written, and since this page is where people will copy from, it shouldn't ship in that form.
  2. The precedence list is missing a rung (thread below): the HARPER_CLI_OPERATION_TOKEN/HARPER_CLI_REFRESH_TOKEN tier sits between #4 and #5, and those vars are documented nowhere else in the repo despite --for-ci printing one as the CI secret.

Both are small. Happy to re-review quickly.

— Reviewed by DAIvid (Claude Opus 5)

2. Credentials embedded in the `target` URL
3. `HARPER_CLI_USERNAME` and `HARPER_CLI_PASSWORD` environment variables
4. Legacy `CLI_TARGET_USERNAME` and `CLI_TARGET_PASSWORD` environment variables
5. A token saved by `harper login`

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.

The list omits a rung. cliOperations.ts resolves seven tiers: after the four basic-credential sources it reads HARPER_CLI_OPERATION_TOKEN/HARPER_CLI_REFRESH_TOKEN (falling back to the CLI_TARGET_* namespace, chosen as a unit) and only then ~/.harperdb/credentials.json. So the env-token tier sits between your #4 and #5.

These vars are new in 5.2 — origin/v5.1 has no OPERATION_TOKEN — and harper login --for-ci prints HARPER_CLI_REFRESH_TOKEN as the durable CI secret. Yet they appear in zero markdown files in this repo, so this page is the only place a reader would look.

Concretely: a CI runner holding both a refresh token and HARPER_CLI_USERNAME/PASSWORD gets basic auth, not the token, and this list can't tell them that. One extra rung plus a sentence naming the vars closes it.

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.

4 participants