Authentication
Token types, proxy auth pipeline, and fail-closed behavior in Phase 1.
Every protected proxy request passes through token validation and agent identity verification before the handler runs. The proxy delegates to the auth service over gRPC — it never stores token hashes locally. For service responsibilities and token issuance, see the Auth service docs.
Token types
IBEX Harness supports several token classes. Each has a different risk profile and rotation policy.
| Type | Lifetime | Typical use | Storage |
|---|---|---|---|
| Personal Access Token (PAT) | Until revoked | SDK and server integrations | Argon2id hash in Postgres |
| Organization token | Rotatable | Production agents | Same as PAT |
| Dashboard session (JWT) | ~1 hour | Operator UI (Phase 2+) | RS256 signed; refresh rotation |
| Service token | ~24 hours | Internal service-to-service | Narrow scopes; auto-rotation |
| Marketplace token | Scoped | Publish/install resources (Phase 3+) | Narrow scope only |
Proxy middleware order
Protected routes run middleware in this order:
Token validation
gRPC ValidateToken resolves org_id and permission bitmap from the bearer token. Invalid, expired, or revoked tokens return 401.
Agent identity
gRPC ValidateAgent(agent_id, org_id_from_token) requires header X-IBEX-Agent-ID. Cross-org or inactive agents return 403 (AGENT_NOT_AUTHORIZED), never 404.
Rate limit
Org-level RPM via Redis. Redis errors fail open per ADR-0015.
Required headers
| Parameter | Type | Description |
|---|---|---|
AuthorizationRequired | string | Bearer token — PAT issued by auth service CreateToken. |
X-IBEX-Agent-IDRequired | uuid | Calling agent UUID; must belong to the org in the URL path. |
Content-TypeRequired | string | application/json on POST bodies with a JSON payload. |
Probe a protected route
curl -s -w "\nHTTP %{http_code}\n" \
-X POST "http://localhost:8080/v1/orgs/${IBEX_DEV_ORG_ID}/chat/completions" \
-H "Authorization: Bearer ${IBEX_DEV_TOKEN}" \
-H "X-IBEX-Agent-ID: ${IBEX_DEV_AGENT_ID}" \
-H "Content-Type: application/json" \
-d '{"model":"gpt-4o","messages":[{"role":"user","content":"ping"}]}'Phase 1 expected: 501 PROVIDER_NOT_CONFIGURED — auth and agent checks passed; provider forwarding is deferred.
Error responses
| HTTP | Code | Meaning |
|---|---|---|
| 401 | MISSING_TOKEN, INVALID_TOKEN | No bearer or token not valid |
| 403 | AGENT_NOT_AUTHORIZED, INSUFFICIENT_PERMISSIONS | Agent wrong org or missing permission bit |
| 503 | AUTH_UNAVAILABLE, SERVICE_DEGRADED | Auth gRPC unreachable or degraded |
All errors use the stable JSON envelope documented in Errors.
Authorization model
Permissions use a 64-bit bitmap (ADR-0009). Phase 1 proxy chat minimum: MemoryRead | SessionCreate | SessionRead. Token create/revoke requires explicit TokenCreate / TokenRevoke bits.
Local dev timeout
Argon2 verify on developer machines can exceed the production 50ms auth budget. If smoke tests return 503, increase the validate timeout:
IBEX_AUTH_VALIDATE_TIMEOUT=2s go run ./services/proxy/cmd/proxySee Troubleshooting for migration and compose-dev issues.
Related
- Issuing API keys
- Proxy authentication
- ADR-0011: Proxy auth client
- ADR-0016: Agent identity verification
Was this page helpful?
Last updated on