Skip to content

refactor(config): move the provider key store to ~/.infer/auth.yaml - #284

Merged
edenreich merged 1 commit into
mainfrom
refactor/auth-yaml
Sep 18, 2026
Merged

edenreich merged 1 commit into
mainfrom
refactor/auth-yaml

Conversation

@edenreich

Copy link
Copy Markdown
Contributor

Summary

Resolves #282.

inference-gateway/cli#1239 renamed the userspace provider-key file to ~/.infer/auth.yaml and removed the auth.json read path. backend/src/config.rs still read and wrote auth.json, so keys entered in Settings -> API Keys landed in a file nothing reads.

The breakage was invisible from inside the app: auth_env() injects the same pairs as environment variables into desktop-spawned infer processes, and the system environment outranks the auth file. It only showed up when running infer from a terminal, where the user got no keys at all.

Straight rename matching the CLI - read and write auth.yaml only, no fallback branch. Users still holding an auth.json re-enter their keys once. serde_norway already backs the config.yaml reader, so this is a serializer swap rather than a new dependency.

Verified against the CLI's current config/auth.go: AuthFileName = "auth.yaml", parsed as a flat map[string]string, no JSON fallback, and a warning when the mode is broader than 0600.

Changes

  • auth_path() returns ~/.infer/auth.yaml; read_auth() / set_auth() go through serde_norway, keeping the 0600 chmod on write
  • In-memory type moves from serde_json::Map<String, serde_json::Value> to BTreeMap<String, String> - what the file and the frontend's Record<string, string> both already are, with deterministic key order on write. get_auth's return type follows; frontend/lib/tauri.ts already typed it that way, so the TS side is unchanged
  • A malformed file now yields no keys rather than dropping individual non-string values, matching the CLI's own reader exactly
  • auth_path / read_auth / the new write_auth_in gain a home-rooted seam so tests run against a temp dir, mirroring the existing read_config / read_config_in pair in the same file. They also drop pub(crate) - only auth_env, get_auth and set_auth are used outside this block
  • Permissions are still set after the write rather than at creation, so an existing file is re-tightened too (OpenOptions::mode() only applies on create)
  • New test covers the missing-file case, the round trip, blank values being dropped, a stray auth.json being ignored, and the 0600 mode - including re-tightening a file left at 0644
  • Stale auth.json references updated: the Settings -> API Keys helper text, the scrub_credentials doc comment in export.rs, and the Export/Import paragraph in the README

Verification

bun run build, cargo fmt --check, cargo clippy --all-targets -- -D warnings, cargo test (159 passed). No e2e run: the DOM contract is untouched - the only frontend edit is body copy, not a button name or element id.

Also checked live against a real ~/.infer/auth.yaml: read_auth() returns all four provider keys and auth_env() passes them through, where the old auth.json path returned none.

Cross-repo

inference-gateway/cli#1239 renamed the userspace provider-key file to
auth.yaml and removed the auth.json read path, so keys saved from Settings
-> API Keys landed in a file nothing reads. Desktop-spawned runs kept
working only because auth_env() injects the pairs as environment variables,
which outrank the auth file - running `infer` from a terminal got no keys.

Straight rename matching the CLI, no fallback read. serde_norway already
backs the config.yaml reader, so this is a serializer swap, not a new dep.
The in-memory type becomes BTreeMap<String, String> - what the file and the
frontend Record<string, string> both already are, with deterministic key
order on write. auth_path/read_auth/write_auth gain a home-rooted seam so
the tests run against a temp dir, mirroring read_config_in.

Resolves #282
@edenreich
edenreich marked this pull request as ready for review September 18, 2026 15:11
@edenreich
edenreich merged commit d265215 into main Sep 18, 2026
1 check passed
@edenreich
edenreich deleted the refactor/auth-yaml branch September 18, 2026 15:11
@inference-gateway-maintainer

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.43.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

@inference-gateway-maintainer inference-gateway-maintainer Bot added the released Shipped in a release label Sep 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

released Shipped in a release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[TASK] Refactor the provider key store to ~/.infer/auth.yaml

1 participant