Skip to content

feat(providers): read provider keys from the freedesktop keyring - #105

Merged
bernardopg merged 4 commits into
mainfrom
feat/keyring-credentials
Nov 8, 2026
Merged

bernardopg merged 4 commits into
mainfrom
feat/keyring-credentials

Conversation

@bernardopg

Copy link
Copy Markdown
Owner

Stacked on #104. Merge the stack bottom-up with a merge commit; until #104 merges, this diff also shows its commits.

Summary

Supersedes #102 and keeps its commit by @alvorithm, with one follow-up commit on top.

Dux Shell runs as a systemd user service, so it never inherits an interactive shell's exports. #102 lets the OpenRouter, Z.ai and OpenCode Go adapters read their key from the freedesktop keyring at the moment of use. The environment carries only a lookup spec such as AIOC_VAULT_OPENROUTER="service openrouter username quota", which is not a secret.

The follow-up commit fix(providers): never prompt from a background keyring lookup changes four things:

  • No unlock prompts from a background refresh. secret-tool lookup unlocks a locked collection before it answers, so each refresh could raise the unlock dialog again. Before reading, the adapter now calls the Secret Service's SearchItems over D-Bus (busctl), which sorts matches into unlocked and locked items without prompting. It skips an entry that is locked or absent. If the bus cannot be asked, the bounded lookup (AIOC_VAULT_TIMEOUT) still runs.
  • No glob expansion. The spec was split by an unquoted expansion, so a * in it matched files in the working directory. It is now split with read -a. A spec that is not attribute/value pairs is ignored, in readiness too. A malformed AIOC_VAULT_TIMEOUT falls back to the default instead of making timeout(1) fail.
  • GLM. The docs listed AIOC_VAULT_ZAI on the GLM row, but the GLM adapter never read it. GLM now reads its own AIOC_VAULT_GLM, in the adapter and in readiness.
  • Docs. The docs now say the key travels through curl's --config pipe, rather than claiming it never reaches a child process. They describe the store/spec workflow and the locked-entry behaviour, and add a troubleshooting pointer.

I verified it against a real Secret Service with a throwaway entry, which I removed afterwards: SearchItems reported unlocked, the key came back, and after secret-tool clear it reported absent and no lookup ran. tests/test-vault-keys.sh uses a fake busctl and secret-tool to cover:

  • a locked entry and an absent entry;
  • an unreachable bus;
  • glob safety and odd-length specs;
  • GLM;
  • a malformed timeout;
  • the existing precedence, bounded-lookup and readiness cases.

Related issues

Supersedes #102.

Type of change

  • New provider
  • Bug fix
  • Enhancement
  • Documentation / i18n
  • CI / tooling

Checklist

  • plugin.json .version and CHANGELOG.md are consistent (not release-bearing; ## Unreleased bullet)
  • New/changed provider scripts are executable and emit valid JSON
  • i18n/en.json keys have translations in every locale (no new strings; readiness details are not translated)
  • Every commit is signed off (git commit -s) under the DCO
  • CI is green

Local gates: check-metadata, check-changelog, check-dco, bash -n, shellcheck -S warning, qmllint, actionlint, gitleaks, every tests/test-*.sh (including the native widget runtime on Wayland), and AIOC_COVERAGE_MIN=95 scripts/coverage.

alvorithm and others added 3 commits November 8, 2026 15:51
A plugin started by the graphical session inherits the user manager's
environment and never an interactive shell's exports, so a key exported in
~/.bashrc never reaches an adapter. The OpenRouter, GLM / Z.ai and OpenCode
Go adapters can now read the key from the keyring at the moment of use.

The environment carries only a lookup spec, AIOC_VAULT_OPENROUTER and its
siblings, which names the secret-tool attributes. The spec is not a secret,
so it can live in a display manager or user-service environment file, and
the key never enters a process environment, a child process, a cache or a
log. An exported key still wins, and AIOC_VAULT_TIMEOUT bounds the lookup so
a locked keyring cannot stall a refresh. Readiness accepts a spec without
performing a lookup, so the settings page cannot raise a prompt.

The test covers the key reaching curl, exported-key precedence, the bound, a
missing secret-tool, and readiness without a lookup.

Signed-off-by: Álvaro Tejero Cantero <[email protected]>
A refresh runs with nobody in front of it, but secret-tool unlocks a
locked collection before it answers, so every refresh could raise the
unlock dialog again. Ask the Secret Service first with SearchItems,
which sorts matches into unlocked and locked items without prompting,
and skip an entry that is locked or absent. The bounded lookup still
covers a bus that cannot be asked.

The spec was split by an unquoted expansion, so a * in it was matched
against the working directory. Split it with read -a instead, and
ignore a spec that is not attribute/value pairs, in readiness too. A
malformed AIOC_VAULT_TIMEOUT now falls back to the default instead of
making timeout(1) fail.

The docs listed AIOC_VAULT_ZAI on the GLM row although the GLM adapter
never read it. GLM now reads its own AIOC_VAULT_GLM, and the docs say
the key travels through curl's --config pipe rather than claiming it
never reaches a child process.

Signed-off-by: Bernardo Pinto Gomes <[email protected]>
@github-actions github-actions Bot added documentation Improvements or additions to documentation area:providers Provider adapters (providers/) area:ci CI, workflows, tooling labels Nov 8, 2026
@bernardopg
bernardopg merged commit c9cc4a2 into main Nov 8, 2026
20 checks passed
@bernardopg
bernardopg deleted the feat/keyring-credentials branch November 8, 2026 19:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:ci CI, workflows, tooling area:providers Provider adapters (providers/) documentation Improvements or additions to documentation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants