feat(mcp): add yt mcp secret rotate #114
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/YT-56-mcp-secret-rotate"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Rotating the Hub client secret had no first-class command. Changing the value alone was always survivable (edit
mcp.env, restart,yt mcp hub reauth --all), but that path is wrong when the rotation is a security response: it re-mints the stored grants rather than dropping them, so credentials derived from a leaked secret keep working. Nothing clearedhub_tokens, browser sessions are signed cookies with no server-side table to clear, andservice installis a full re-declaration that would silently reset--hub-scope(YT-55) while preserving the session key by design. What was left was a hand-edited 0600 env file, a base64 key generated by hand,DELETEstatements against an encrypted SQLite database, and a manual restart, with a silent failure mode at every step.yt mcp secret rotatedoes the whole response in one command, ordered so nothing local changes until the new secret exists upstream: install a new secret on the Hub service record (authenticating with the active instance's YouTrack token, never with the secret being replaced), patch onlyYOUTRACK_MCP_HUB_CLIENT_SECRETandYOUTRACK_MCP_SESSION_KEYinmcp.envvia temp file plus rename at 0600, purgehub_tokens/access_tokens/refresh_tokens/authorization_codesin one transaction, andsystemctl --user restartthe unit. A Hub that refuses fails closed: the env is byte-identical and the operator re-runs with--hub-client-secret <value>, which skips the Hub call and applies a value they rotated by hand.--yesskips the confirmation,--no-restartleaves the restart to the caller.The env write is a patch, never a re-declaration, so no key the operator did not name can be reset.
YOUTRACK_MCP_MASTER_KEYis left alone: it protectshub_tokensat rest and the purge deletes every such row.Tests cover the patch preserving unrelated keys, the purge emptying all four tables, a failing Hub call leaving
mcp.envuntouched, the restart never reaching forenable --now, and an end-to-end case proving a bearer minted under the old secret dies at once while the same session cookie runs a full Hub login and its tool calls succeed, with no manual cookie clearing.#YT-56
yt mcp secret rotate