# Users and keys

Every call through Godelgate belongs to a user. Each user has a key, which their MCP client sends as a bearer token, and a list of groups that [policy rules](/docs/policy) can target.

```yaml
users:
  - name: alice
    key: ${ALICE_KEY}
    groups: [engineering]
  - name: bob
    key: ${BOB_KEY}
    groups: [sales]
  - name: nightly-report-agent
    key: ${REPORT_AGENT_KEY}
    groups: [agents]
```

| Field | Required | Description |
| --- | --- | --- |
| `name` | yes | Shown in the dashboard and audit log |
| `key` | yes | At least 16 characters. Use `${VAR}` to read it from the environment. |
| `groups` | no | Group names for rules, default `[]` |

## Generating keys

```bash
openssl rand -hex 24
```

Store keys in your secret manager and inject them as environment variables. Don't commit them in `godelgate.yaml`.

## People and agents

Give unattended agents their own user instead of reusing a person's key. Then you can write stricter rules for them, for example denying instead of queuing approvals nobody will see, and the audit log shows exactly which agent did what.

## Rotating a key

1. Set the new value of the user's variable.
2. Restart Godelgate.
3. Update the user's client. Sessions opened with the old key stop working.

## Admin access

The dashboard and `/api/*` use a separate admin token, set with `GODELGATE_ADMIN_TOKEN` or `admin.token`. User keys can't access the admin API.

> Single sign-on (OIDC) is on the roadmap. Until then, keys are the way to tie calls to people.
