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
Copy file name to clipboardExpand all lines: assets/agw-docs/pages/agentgateway/llm/virtual-keys.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -62,8 +62,8 @@ Store your virtual keys in a Kubernetes ConfigMap, with one entry per user. Beca
62
62
1. Generate a `sha256:<hex>` hash for each user's API key. The hash is computed over the exact key bytes, so do not include a trailing newline.
63
63
64
64
```sh
65
-
printf'%s''sk-alice-abc123def456'| sha256sum # alice
66
-
printf'%s''sk-bob-xyz789uvw012'| sha256sum # bob
65
+
printf'%s''sk-alice-abc123def456'| sha256sum | awk '{print "sha256:"$1}'# alice
66
+
printf'%s''sk-bob-xyz789uvw012'| sha256sum | awk '{print "sha256:"$1}'# bob
67
67
```
68
68
69
69
2. Create a ConfigMap that stores the hash and metadata for each user. Add a label so that the authentication policy can select the ConfigMap in the next step.
@@ -147,7 +147,7 @@ EOF
147
147
### Configure API key authentication
148
148
149
149
{{< version exclude-if="1.3.x,1.2.x,1.1.x,1.0.x,2.2.x" >}}
150
-
Create an {{< reuse "agw-docs/snippets/policy.md" >}} that requires API key authentication for all requests to the gateway. Use `configMapSelector` to select every ConfigMap that carries the label you added in the previous step. ConfigMap sources are selected by label only, so this also selects a single ConfigMap by its label.
150
+
Create an {{< reuse "agw-docs/snippets/policy.md" >}} that requires API key authentication for all requests to the gateway. Unlike Secrets, which you can reference directly by name, ConfigMaps can be selected only by label. Use `configMapSelector` to match every ConfigMap that carries the label you added in the previous step, whether that is a single ConfigMap or several.
151
151
152
152
```yaml,paths="virtual-keys"
153
153
kubectl apply -f- <<EOF
@@ -780,7 +780,7 @@ Provide different budget tiers for free, standard, and premium users.
780
780
1. Add tier metadata to each API key.
781
781
782
782
{{< version exclude-if="1.3.x,1.2.x,1.1.x,1.0.x,2.2.x" >}}
783
-
Store the keys in a ConfigMap, using the `keyHash` of each key. Generate each hash with `printf '%s' '<key>' | sha256sum`.
783
+
Store the keys in a ConfigMap, using the `keyHash` of each key. Generate each hash with `printf '%s' '<key>' | sha256sum | awk '{print "sha256:"$1}'`.
3. Create a ConfigMap to store your API key hashes. Each entry represents one valid API key, as a JSON object with a `keyHash` and optional `metadata`. Add a label so that the policy can select the ConfigMap.
@@ -160,7 +160,7 @@ Store your API keys in a Kubernetes secret so that you can reference it in an {{
160
160
kubectl get secret apikey -n {{< reuse "agw-docs/snippets/namespace.md">}} -oyaml
161
161
```
162
162
163
-
4. Create an {{< reuse "agw-docs/snippets/policy.md" >}} resource that configures API key authentication for all routes that the Gateway serves and reference the `apikey` secret that you created earlier. The following example uses the `Strict` validation mode, which requires request to include a valid `Authorization` header to be authenticated successfully. For other common configuration examples, see [Other configuration examples](#other-configuration-examples).
163
+
4. Create an {{< reuse "agw-docs/snippets/policy.md" >}} resource that configures API key authentication for all routes that the Gateway serves and reference the `apikey` secret that you created earlier. The following example uses the `Strict` validation mode, which requires requests to include a valid `Authorization` header to be authenticated successfully. For other common configuration examples, see [Other configuration examples](#other-configuration-examples).
0 commit comments