Skip to content

Key logins by the registry without its trailing slash - #1113

Merged
tolgaergin merged 2 commits into
review/doctor-store-dlx-pluginsfrom
review/registry-session-keys
Nov 8, 2026
Merged

tolgaergin merged 2 commits into
review/doctor-store-dlx-pluginsfrom
review/registry-session-keys

Conversation

@tolgaergin

@tolgaergin tolgaergin commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Problem

A login was stored under the registry URL exactly as given. lpm login --registry https://lpm.dev/ saved a session that a later command for https://lpm.dev didn't see. The exchange and refresh requests went to //api/.... Trimming the slash at startup wasn't possible either: logins already stored under the slashed spelling would have disappeared. That's why the first attempt was reverted in #1099.

Change

  • Keys: lpm-auth derives every credential key from the registry without trailing slashes. That covers keychain accounts, encrypted-file keys, credential-authority records, the session lock, and the expiry and OTP metadata.
  • Migration: when a read finds nothing under that key, it reads the slashed spelling using the old key derivation. It moves what it finds, with its expiry metadata, to the new key under the same credential store lock, then clears the slashed copy. Logout clears both spellings.
  • Trimming: dispatch trims the registry once at startup, and SessionManager::new trims what it's given. That fixes every {registry_url}/api/... URL built from it.
  • MCP server: it derives the same keychain account names, so it changes in lockstep in lpm-dev/mcp-server (linked below). The new MCP release reads the trimmed account first, then the slashed one, so it works with logins stored by older and newer CLI releases. An older MCP server with a slashed LPM_REGISTRY_URL won't find a login the new CLI stored. The default URL has no slash, so this doesn't affect it.

Tests

  • a_login_stored_under_a_trailing_slash_url_is_found_without_it (workflow, failed before: whoami missed the login)
  • both_spellings_of_a_registry_name_one_login, a_login_stored_under_a_trailing_slash_moves_to_the_registry_key, logging_out_also_clears_a_login_stored_under_a_trailing_slash
  • scoped_account_matches_mcp_known_answer_vectors now expects https://lpm.dev/ to map to the trimmed account, and pins the old slashed account.
  • cache_status_uses_cli_registry_for_the_default_remote_cache_origin, which forced the revert in Fix dev and infra command bugs found in a performance and correctness review #1099, passes with the trim now in place.
  • lpm-auth passes 3 runs in a row; the auth, cache, logout, setup and publish workflow suites pass.

Docs: lpm-dev/rust-client-docs#455. MCP server: lpm-dev/mcp-server#3.

Council review follow-up

  • A slashed login moves whole, access and refresh tokens with their session metadata, and only while the registry key has no credential or authority record, so two logins never pair up. A partial move is undone.
  • Clearing a credential under the registry key, as logout or a rejected session does, retires the slashed login, so it can't return afterwards.
  • Tests: a_trailing_slash_login_is_not_merged_into_the_login_under_the_registry_key, a_trailing_slash_login_moves_its_tokens_and_session_metadata_together, a_trailing_slash_login_does_not_return_once_the_newer_login_is_rejected, a_trailing_slash_login_does_not_replace_a_revoked_credential.

🤖 Generated with Claude Code

tolgaergin and others added 2 commits November 8, 2026 05:29
A login was stored under the registry URL exactly as given, so
`lpm login --registry https://lpm.dev/` saved a session that a later
command for https://lpm.dev didn't see, and `/api/cli/exchange` and the
refresh were requested at `//api/...`. The trailing slash couldn't simply
be trimmed when the CLI started, since that would have hidden logins
already stored under the slashed spelling.

lpm-auth now derives every credential key without trailing slashes: the
keychain accounts, the encrypted-file keys, the credential authority
records, the session lock and the expiry and OTP metadata. When a read
finds nothing under that key, it reads the slashed spelling as earlier
releases keyed it, and moves what it finds, with its expiry metadata, to
the new key under the same store lock. Logout clears both spellings.
With that, the CLI trims the registry once when it starts, and the
session manager trims what it's given, which fixes every `/api/...` URL
built from it.

The MCP server derives the same keychain account names and changes with
this (lpm-dev/mcp-server).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The move took an access and a refresh credential separately, so one login's
access token could pair with another's refresh token, and a login cleared
under the registry key made room for the slashed one to return. A slashed
login now moves whole, with its session metadata and undone on a partial
failure, only while the registry key has no credential or authority record.
Clearing a credential under the registry key retires the slashed login.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tolgaergin
tolgaergin force-pushed the review/registry-session-keys branch from f677de8 to a534b64 Compare November 8, 2026 05:42
@tolgaergin
tolgaergin merged commit 2706d74 into main Nov 8, 2026
37 of 55 checks passed
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.

1 participant