IBEX Harness
DocsBenchmarksBlogChangelogRoadmap
GitHub
IBEX Harness

Documentation

Architecture Decision RecordsADR-0002: Repository foundation bootstrapADR-0003: Branch protection and merge policyADR-0004: Protobuf and code generation policyADR-0005: Postgres migration strategyADR-0006: Auth protobuf contract (`ibex.auth.v1`)ADR-0007: Auth token validation implementationADR-0008: Security scanning and CI quality gatesADR-0009: Permission bitmap layoutADR-0010: Cryptography policyADR-0011: Proxy auth gRPC client and middlewareADR-0012: Proxy request normalization (OpenAI chat)ADR-0013: Proxy input validation and stable error envelopeADR-0014: Core domain migration sequencingADR-0015: Proxy rate limit skeleton (Phase 1)ADR-0016: Proxy agent identity verification (Phase 1)ADR-0017: Request ID and trace context strategy (Phase 1)ADR-0018: Graceful shutdown contract (Phase 1)ADR-0019: OpenTelemetry provider configuration (Phase 1)ADR-0020: Shared package boundaries — `packages/config` and `packages/apierror`ADR-0021: Prometheus Metric Catalog (Phase 1)ADR-0022: Health check contract (Phase 1)ADR-0023: Docs site architecture (Phase 1.5)ADR-0024: Benchmark data publishing modelADR-0025: LLM provider abstractionADR-0026: OpenAI client designADR-0027: Streaming dual-write strategyADR-0028: Auth cache designADR-0029: Token revocation propagation via Redis pub/subADR-0030: Directive versioning strategyADR-0031: System prompt injection strategyADR-0032: Session data model and retentionADR-0033: ClickHouse llm_traces schema and retentionADR-0034: Proxy overhead performance measurement methodologyADR-0035: Chat Idempotency-Key Redis dedupeADR-0038: Context assembly service design and gRPC contractADR-0039: Proxy Postgres ownership for session and directive storesADR-0040: Anthropic provider adapterADR-0041: Model capability registryADR-0042: Self-hosted OpenAI-compatible LLM adapterADR-0043: Tokenizer registry architectureADR-0044: Non-streaming response pipelineADR-0045: Streaming response transformationADR-0046: Embedder interface and profile registryADR-0047: Memory temporal validity foundationADR-0048: Memory multi-label categoriesADR-0049: Memory relationship graph readinessADR-0050: MCP server skeleton (transport, auth, audit)ADR-0051: Local LGTM observability stack (Phase 2.5 exit pull-forward)ADR-0052: Memory schema v2 expand (HNSW, quality columns)ADR-0053: Vector store abstraction and composite scoring v2
ADRs›ADR-0011: Proxy auth gRPC client and middleware
ADRs

ADR-0011: Proxy auth gRPC client and middleware

Architecture decision record 0011.

ADR-0011: Proxy auth gRPC client and middleware

  • Status: Accepted
  • Date: 2026-06-04
  • Authors: IBEX Harness team

Context

Milestone 1.1.3 delivered auth ValidateToken (ADR-0007). The proxy skeleton (services/proxy) exposes health/metrics only. Milestone 1.2.1 connects the proxy to auth so protected routes receive org_id and permission context before LLM normalization (1.2.2).

ARCHITECTURE.md describes a future bloom filter + LRU cache pipeline. Phase 2 optional milestone 2.2.1-auth-cache-bloom owns that work; v1 uses remote validation only (SECURITY.md §15: fail closed when validation cannot complete).

Decision

1) Transport and connection

  • gRPC to ibex.auth.v1.AuthService/ValidateToken (ADR-0006)
  • Single shared *grpc.ClientConn per proxy process; dial at startup; close on shutdown
  • Development: insecure credentials; production: mTLS (documented follow-up, not in v1)

2) Timeouts

  • Default per-validate timeout: 50ms (IBEX_AUTH_VALIDATE_TIMEOUT)
  • Use context.WithTimeout derived from the HTTP request context
  • Exceeded deadline → HTTP 503 SERVICE_DEGRADED (fail closed)

3) Bearer parsing

  • Read Authorization: Bearer <token>
  • Strip the Bearer prefix and following space; pass PAT wire string (ibex_pat_...) as ValidateTokenRequest.access_token
  • Missing header → HTTP 401 MISSING_TOKEN
  • Invalid/revoked → HTTP 401 INVALID_TOKEN (maps gRPC Unauthenticated)

4) Request context

After successful validation, attach to context.Context:

  • org_id, permissions (int64), optional agent_id, user_id, token_id

Handlers read via auth.FromContext(ctx).

5) Permission and tenant checks

  • Chat routes require permissions.ProxyChatCompletion (ADR-0009)
  • Path-scoped routes (e.g. /v1/orgs/{org_id}/...) compare path org_id to token org → 403 on mismatch

6) HTTP error mapping

Minimal stable JSON envelope in services/proxy/internal/errors/ (extended by milestone 1.2.3):

ConditionHTTPcode
Missing Authorization401MISSING_TOKEN
Invalid token401INVALID_TOKEN
Insufficient permissions / org mismatch403INSUFFICIENT_PERMISSIONS
Auth unreachable / timeout / internal503SERVICE_DEGRADED

7) Auth validation cache (implemented — 2.2.1)

Implemented: In-process invalid-token bloom + claims LRU via packages/authcache wrapping auth.TokenValidator. See ADR-0028. Max revoke lag without pub/sub is the LRU TTL (30s); ADR-0029 / milestone 2.2.2 adds Invalidate fan-out for the 5s exit gate.

Still deferred: RedisBloom / distributed claims cache; agent validation cache.

Extension point: auth.TokenValidator; GRPCValidator + WrapWithCache decorator.

Historical note: Phase 1 deferred caching for fail-closed correctness before latency optimization; that deferral is closed by 2.2.1.

8) Observability

  • Metrics: ibex_proxy_auth_validate_total, ibex_proxy_auth_validate_duration_seconds
  • Label: result only (ok, unauthenticated, error) — no org_id
  • Logs: may include org_id, token_id after success; never log bearer or access_token

9) Middleware order

metrics → logging → auth → handler (future: body limit, rate limit before handler)

10) Public routes (no auth)

/health, /ready, /metrics remain unauthenticated.

Consequences

Positive

  • Phase 1 exit criterion: proxy rejects unauthenticated traffic
  • Auth cache decorator shipped in 2.2.1 (ADR-0028)

Negative

  • Without 2.2.2 pub/sub, revoked tokens may remain in LRU up to 30s
  • 50ms budget may require tuning under load

References

  • Milestone 1.2.1
  • ADR-0006
  • ADR-0007

Was this page helpful?

Edit on GitHub

Last updated on

PreviousADR-0010: Cryptography policyNextADR-0012: Proxy request normalization (OpenAI chat)

On this page

  • Context
  • Decision
  • 1) Transport and connection
  • 2) Timeouts
  • 3) Bearer parsing
  • 4) Request context
  • 5) Permission and tenant checks
  • 6) HTTP error mapping
  • 7) Auth validation cache (implemented — 2.2.1)
  • 8) Observability
  • 9) Middleware order
  • 10) Public routes (no auth)
  • Consequences
  • Positive
  • Negative
  • References
0%