From df1b86a5a5fbf788d6070105c81080631c8cd899 Mon Sep 17 00:00:00 2001 From: Lukasz Raczylo Date: Sun, 29 Nov 2026 00:21:53 +0000 Subject: [PATCH] docs: correct failOpen, reload and anonymous access text --- README.md | 28 +++++++++++++--------- readme_anonymous_example_test.go | 40 ++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 11 deletions(-) create mode 100644 readme_anonymous_example_test.go diff --git a/README.md b/README.md index 5157c63..d9c112a 100644 --- a/README.md +++ b/README.md @@ -242,22 +242,21 @@ that still has requests after `-reload-drain-timeout` closes anyway. [`requestTimeout`](#request-timeout) — a progress-based watchdog, five minutes by default — not a proxy deadline. -- **Config changes need a restart.** Traefik rebuilds the plugin - automatically on a CR change; a binary has no such hook. Roll the pods - by putting a checksum of the `ConfigMap` in the Deployment's pod - annotations, so an ArgoCD sync restarts them. There is deliberately no - SIGHUP and no file watcher: a rebuild re-runs the synchronous discovery - warm-fill, and a single-file watch never fires on a `ConfigMap` update - anyway (the kubelet swaps the whole directory's symlink). +- **Config changes reload on their own.** Traefik rebuilds the plugin + automatically on a CR change. The binary reloads when the file content + changes and on `SIGHUP`; see [Config reload in the binary](#config-reload-in-the-binary). + A checksum of the `ConfigMap` in the Deployment's pod annotations, so an + ArgoCD sync restarts the pods, is optional. **The users file is the exception and needs none of this.** It still hot-reloads on its own 5-second mtime poll from the request path, exactly as in the plugin form. Do not add a watcher for it — it would race the existing one. -- **Provider keys resolve once, at construction**, in both forms. Rotating - one means a restart even though the mounted file changed. Only - file-sourced *user* keys re-resolve on the users-file reload. +- **Provider keys resolve once per gateway build.** In the binary, `SIGHUP` + rebuilds the gateway and picks up a rotated `file:` provider key. In the + plugin form, a rebuild is the only way. Only file-sourced *user* keys + re-resolve on the users-file reload. - **Mount the same secret volumes.** A `file:/llmgw/providers/openai` `apiKey` reads that exact path in the binary too. Reproduce the volumes, @@ -751,7 +750,11 @@ as the reserved user `anonymous` in that group: ```yaml groups: public: + providers: ["openai"] models: ["gpt-5-mini"] + mcpServers: ["-none-"] + agents: ["-none-"] + passthroughPaths: ["-none-"] limits: { requestsPerDay: 5000 } memberLimits: { requestsPerMinute: 30 } users: @@ -780,6 +783,9 @@ to serve those requests as `anonymous` too: - The admin API and the metrics key fallback still need a valid admin key. Anyone who can reach the gateway can spend the providers this group allows. +An empty `mcpServers`, `agents` or `passthroughPaths` list on this group +allows every MCP server, A2A agent and native passthrough path. The example +sets each to a pattern that matches no name (`-none-`) to deny them. Set group `limits` and `memberLimits`, and restrict who can reach the route at the proxy. @@ -3543,7 +3549,7 @@ plugin's config. a temporary gap in the series is the honest signal; a fabricated `0` would read to Prometheus as a counter reset followed by a phantom spike the instant the store recovers. This holds regardless of - `redis.failOpen`: with `failOpen: false` (or unset) the request itself + `redis.failOpen`: with `failOpen: false` the request itself is refused during the outage, and with `failOpen: true` (the default) requests keep flowing against the in-process fallback, but `/metrics` still treats the affected scopes as unreadable rather than presenting diff --git a/readme_anonymous_example_test.go b/readme_anonymous_example_test.go new file mode 100644 index 0000000..89f72f7 --- /dev/null +++ b/readme_anonymous_example_test.go @@ -0,0 +1,40 @@ +package traefikllmgateway + +import ( + "net/http" + "net/http/httptest" + "testing" +) + +// The values mirror the README "Anonymous access" example. +func TestReadmeAnonymousExample_DeniesTargets(t *testing.T) { + cfg := &Config{ + Providers: map[string]*ProviderConfig{"openai": {Type: "openai", APIKey: "k"}}, + Groups: map[string]*GroupConfig{ + "public": { + Providers: []string{"openai"}, + Models: []string{"gpt-5-mini"}, + MCPServers: []string{"-none-"}, + Agents: []string{"-none-"}, + PassthroughPaths: []string{"-none-"}, + Limits: &LimitsConfig{RequestsPerDay: 5000}, + MemberLimits: &LimitsConfig{RequestsPerMinute: 30}, + }, + }, + Users: &UsersConfig{AnonymousGroup: "public"}, + } + a, err := newAuthStore(cfg) + if err != nil { + t.Fatal(err) + } + _, grp, ok := a.identify(httptest.NewRequest(http.MethodPost, "/v1/chat/completions", nil)) + if !ok { + t.Fatal("anonymous request not identified") + } + if grp.allowsMCP("docs") || grp.allowsAgent("planner") || grp.allowsPassthroughPath("v1/files") { + t.Fatal("README anonymous example allows an MCP server, agent or passthrough path") + } + if !grp.allowsProvider("openai") { + t.Fatal("README anonymous example denies its own provider") + } +}