Skip to content

Commit 3a7b436

Browse files
soumya-ioclaude
andcommitted
Move authentication details from quickstart to dedicated how-to guide
Replace the inline authentication note and docker command in quickstart.mdx with a short callout linking to the new guide. Create how-to/enable-authentication.mdx with step-by-step instructions for enabling API key auth, the two-tier key model, key rotation, and troubleshooting. Add the new page to docs.json navigation. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 510ec64 commit 3a7b436

3 files changed

Lines changed: 114 additions & 17 deletions

File tree

core/quickstart.mdx

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -186,22 +186,9 @@ Now, run your agent code.
186186

187187
**🎉 Done!** Your agent now blocks SSN patterns automatically.
188188

189-
> [**!NOTE**]
190-
> **Authentication Note:** Authentication is disabled by default in the server .env (`AGENT_CONTROL_API_KEY_ENABLED=false`). If you enable it, this setup script needs an admin API key because it creates a control and attaches it to an agent. `agents.register_agent()` accepts a regular or admin key, but `controls.create_control()` and `agents.add_agent_control()` require a key listed in `AGENT_CONTROL_ADMIN_API_KEYS`.
191-
>
192-
> In the example .env, the placeholders are:
193-
>
194-
> - **Regular API key(s):** `AGENT_CONTROL_API_KEYS` (e.g., "my-ui-key")
195-
> - **Admin API key(s):** `AGENT_CONTROL_ADMIN_API_KEYS` (e.g., "my-admin-key")
196-
>
197-
> **Replace these defaults before any shared or production deployment.**
198-
199-
**With authentication enabled:**
200-
201-
```bash
202-
curl -L https://raw.githubusercontent.com/agentcontrol/agent-control/refs/heads/main/docker-compose.yml | AGENT_CONTROL_API_KEY_ENABLED=true AGENT_CONTROL_API_KEYS="my-ui-key" AGENT_CONTROL_ADMIN_API_KEYS="my-admin-key" AGENT_CONTROL_SESSION_SECRET="some-long-random-string" CORS_ORIGINS="http://localhost:4000" docker compose -f - up -d
203-
```
204-
189+
<Note>
190+
Authentication is disabled by default for local development. When you're ready to deploy, see the [Enable Authentication](/how-to/enable-authentication) guide.
191+
</Note>
205192

206193
### What Is Happening Under the Hood
207194

docs.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@
5757
{
5858
"group": "How-to Guides",
5959
"pages": [
60-
"how-to/decorate-llm-tool-calls"
60+
"how-to/decorate-llm-tool-calls",
61+
"how-to/enable-authentication"
6162
]
6263
},
6364
{

how-to/enable-authentication.mdx

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
---
2+
title: Enable Authentication
3+
description: Secure your Agent Control server with API key authentication for shared and production deployments.
4+
icon: "lock"
5+
---
6+
7+
Authentication is disabled by default so you can get started quickly in local development. Before sharing your server or deploying to production, enable API key authentication to protect the control plane from unauthorized access.
8+
9+
## How It Works
10+
11+
Agent Control uses a two-tier API key model:
12+
13+
| Key type | Environment variable | What it can do |
14+
|----------|---------------------|----------------|
15+
| **Regular** | `AGENT_CONTROL_API_KEYS` | Register agents, evaluate controls, read controls and agents |
16+
| **Admin** | `AGENT_CONTROL_ADMIN_API_KEYS` | Everything above **plus** create/update/delete controls and manage agent-control associations |
17+
18+
The `/health` endpoint is always public and requires no authentication.
19+
20+
<Tip>
21+
Give your agent runtime a **regular** key. Reserve **admin** keys for setup scripts, CI pipelines, and the UI dashboard.
22+
</Tip>
23+
24+
## Step-by-Step Setup
25+
26+
<Steps>
27+
<Step title="Start the server with authentication enabled">
28+
29+
Pass the authentication environment variables when starting the server:
30+
31+
```bash
32+
curl -L https://raw.githubusercontent.com/agentcontrol/agent-control/refs/heads/main/docker-compose.yml \
33+
| AGENT_CONTROL_API_KEY_ENABLED=true \
34+
AGENT_CONTROL_API_KEYS="my-runtime-key" \
35+
AGENT_CONTROL_ADMIN_API_KEYS="my-admin-key" \
36+
AGENT_CONTROL_SESSION_SECRET="some-long-random-string" \
37+
CORS_ORIGINS="http://localhost:4000" \
38+
docker compose -f - up -d
39+
```
40+
41+
<Warning>
42+
Replace the placeholder key values above with strong, unique secrets before any shared or production deployment.
43+
</Warning>
44+
45+
</Step>
46+
47+
<Step title="Pass the API key from the SDK">
48+
49+
The SDK reads the `AGENT_CONTROL_API_KEY` environment variable by default, or you can pass it explicitly:
50+
51+
```python
52+
from agent_control import AgentControlClient
53+
54+
# Option 1: Environment variable (recommended)
55+
# export AGENT_CONTROL_API_KEY="my-runtime-key"
56+
async with AgentControlClient() as client:
57+
await client.health_check()
58+
59+
# Option 2: Explicit constructor argument
60+
async with AgentControlClient(api_key="my-runtime-key") as client:
61+
await client.health_check()
62+
```
63+
64+
</Step>
65+
66+
<Step title="Use an admin key for control management">
67+
68+
Operations that modify controls or agent-control associations require an admin key. This keeps your control plane locked down even if a runtime key is compromised.
69+
70+
```python
71+
# setup.py — run with an admin key
72+
async with AgentControlClient(api_key="my-admin-key") as client:
73+
await controls.create_control(client, name="block-ssn", data={...})
74+
await agents.add_agent_control(client, agent_name="my-agent", control_id="...")
75+
```
76+
77+
</Step>
78+
79+
<Step title="Include the key in direct API calls">
80+
81+
If calling the REST API directly, include the key in the `X-API-Key` header:
82+
83+
```bash
84+
curl -H "X-API-Key: my-runtime-key" \
85+
http://localhost:8000/api/v1/agents
86+
```
87+
88+
</Step>
89+
</Steps>
90+
91+
## Key Rotation
92+
93+
Agent Control accepts multiple comma-separated keys per variable, making zero-downtime rotation straightforward:
94+
95+
1. Add the new key alongside the old one: `AGENT_CONTROL_API_KEYS="old-key,new-key"`
96+
2. Redeploy the server
97+
3. Update all clients to use the new key
98+
4. Remove the old key: `AGENT_CONTROL_API_KEYS="new-key"`
99+
5. Redeploy again
100+
101+
## Troubleshooting
102+
103+
**401 Unauthorized** — check these in order:
104+
105+
1. Authentication is enabled (`AGENT_CONTROL_API_KEY_ENABLED=true`)
106+
2. Your key is present in the correct variable (`AGENT_CONTROL_API_KEYS` for regular, `AGENT_CONTROL_ADMIN_API_KEYS` for admin operations)
107+
3. The `X-API-Key` header (or SDK `api_key` argument) matches exactly — no trailing whitespace or quotes
108+
109+
See the [Authentication reference](/core/reference#authentication) for the full configuration table.

0 commit comments

Comments
 (0)