Repository navigation
feat(auth): add ~/.infer/auth.json as userspace provider key fallback - #1169
Merged
Merged
Conversation
provider api keys now resolve per key with first hit winning: system environment, project .env, then the new ~/.infer/auth.json fallback (a flat json map of provider key env vars). the loader lives in config/ and is shared by all three resolution paths: gateway container run, gateway binary mode, and a2a agent containers. missing, empty, or unreadable files degrade silently; malformed json or permissions broader than 0600 are logged as warnings by the callers.
4 tasks
inference-gateway-maintainer
Bot
marked this pull request as ready for review
September 3, 2026 12:30
inference-gateway-maintainer
Bot
requested a review
from a team
as a code owner
September 3, 2026 12:30
5 tasks
edenreich
reviewed
Sep 3, 2026
edenreich
reviewed
Sep 3, 2026
edenreich
reviewed
Sep 3, 2026
edenreich
reviewed
Sep 3, 2026
edenreich
reviewed
Sep 3, 2026
Contributor
|
🎉 This PR is included in version 0.189.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
5 tasks
edenreich
added a commit
that referenced
this pull request
Sep 18, 2026
auth.yaml is the only provider-key file the CLI looks at. The legacy read, its constant, the two fallback test cases and the auth.json protected_paths entry are gone, along with the migration prose in the README and docs. Also sweeps the stale auth.json references left behind by #1169 in internal/gateway and internal/agent/application, and switches the gateway env fixtures from JSON bodies to the YAML users actually write.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolves #1167
Summary
Adds
~/.infer/auth.jsonas a userspace fallback for provider API keys when they are not supplied by a higher-precedence source. Keys now resolve per key with first hit winning: system environment, project.env, then~/.infer/auth.json(a flat JSON map of provider key env vars). The read is implemented once inconfig/and shared by all three resolution paths, so the fallback behaves identically for the gateway container, gateway binary mode, and A2A agent containers.Changes
config/auth.go:AuthFilePath()andLoadAuthKeys()- reads~/.infer/auth.jsonasmap[string]string. Missing/unreadable/empty files degrade silently (no keys, no warnings); malformed JSON yields no keys (nothing partially parsed) plus a warning; permissions broader than0600warn.configcannot import the platform logger (the logger importsconfig), so warnings are returned for callers to log.internal/gateway/manager.gorunContainer()(container mode): the whole.envstill goes via--env-file;-eis now also passed for keys resolved from theauth.jsonfallback, but never for keys present in.env(soauth.jsoncannot override the project.env, and the system env-estill wins over--env-file).internal/gateway/manager.goloadEnvironment()(binary mode): explicit precedence via first-hit dedup - system env, then.envlines for keys not already set, thenauth.json. This also makes binary mode deterministic instead of relying on the child process' duplicate-env handling, matching container mode.internal/agent/application/agent_manager.go:auth.jsonis the final fallback when resolving env vars for A2A agent containers (after.env, system environment, and the agent's own config value; empty config values fall through to the fallback). The resolution loop is extracted intoresolveAgentEnvso the order is unit-testable without docker.config/auth_test.go(loader cases: missing, empty, malformed, valid, broad perms, unreadable),internal/gateway/manager_env_test.go(binary-mode precedence: system >.env>auth.json, empty values skipped, missing/malformed degrade),TestResolveAgentEnv(A2A resolution order).docs/configuration-reference.mdnow document~/.infer/auth.jsonand the precedence order.Behavior change
Binary mode previously appended
.envlines after the system environment, and Go'sexeckeeps the last duplicate, so.envsilently overrode system env vars. This PR flips binary mode to system-wins, matching container mode and the documented order.Notes
ProtectedPaths:auth.jsonwas already protected (agents cannot read or edit it).infer auth login/ keychain integration intentionally out of scope (follow-up); the file is trivially hand-editable.Follow-ups