You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Adds support for conditionally enabling/disabling authentication via
environment variables, following the same pattern as inference
providers.
Key features:
- Auth provider can be enabled/disabled using
${env.AUTH_PROVIDER:+oauth2_token} syntax in config.yaml
- When AUTH_PROVIDER env var is set, auth is enabled; when unset, auth
is completely disabled (no middleware initialized)
- Allows same config.yaml to work across dev/staging/prod environments
- Added to ci-tests distribution as example and for testing
Implementation:
- Special handling in replace_env_vars() intercepts auth config before
Pydantic validation
- When type field resolves to None/empty, entire provider_config is set
to None to avoid discriminated union validation errors
- remove auth provider_config during list-deps, it isn't used and as
config hasn't passed through replace_env_vars fails syntax checks
Changes:
- src/llama_stack/core/stack.py: Add conditional auth handling
- src/llama_stack/distributions/template.py: Add auth_config field to
RunConfigSettings
- src/llama_stack/distributions/ci-tests/: Add conditional auth config
- docs/docs/distributions/configuration.mdx: Document conditional auth
- tests/unit/server/test_replace_env_vars.py: Add tests
- src/llama_stack/cli/stack/_list_deps.py: remove auth provider_config
Related to #4365
Signed-off-by: Derek Higgins <derekh@redhat.com>
Copy file name to clipboardExpand all lines: docs/docs/distributions/configuration.mdx
+30Lines changed: 30 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -288,6 +288,36 @@ The `auth` section configures authentication for the server. When configured, al
288
288
Authorization: Bearer <token>
289
289
```
290
290
291
+
#### Conditional Authentication
292
+
293
+
Authentication can be conditionally enabled or disabled using environment variables with the conditional syntax (`:+`). This is useful for deploying the same configuration to different environments where auth may or may not be required.
0 commit comments