ibexharness
DocsBlogReleasesRoadmap
GitHub
ibexharness

Documentation

OverviewIssuing API keysOrg and project modelMulti-tenant RLS
Auth›Org and project model
Auth

Org and project model

How organizations, projects, and agents relate in Phase 1.

IBEX Harness scopes all runtime identity to an organization. Agents belong to exactly one org; tokens are issued per org and encode a permission bitmap for that tenant. The proxy derives org_id from the validated PAT — never from request body fields.

Projects in Phase 1

The schema reserves project boundaries for later phases. Phase 1 proxy paths use org scope only — project-scoped URLs and memory isolation arrive with dashboard and memory services.

Entity hierarchy

Mermaid diagram: erDiagram
+--------------+      +------+         
| ORGANIZATION ||---o<| USER |         
+--------------+ has  +------+         
        |                 |            
    ------issues----------- may_create 
    |   |          |      |            
   o<   |         o<      |            
+-------+      +-------+               
| AGENT ||---o<| TOKEN |               
+-------+may_bi+-------+               
                                       
                                       
1

Organization

Top-level tenant. Owns agents, tokens, and rate-limit buckets. Table: ibex_core.organizations.

2

User

Human operator (Phase 1 subset). Linked to org membership for token issuance audit. Table: ibex_core.users.

3

Agent

Autonomous actor that calls the proxy. Identified by X-IBEX-Agent-ID on every protected request. Table: ibex_core.agents.

4

Token

PAT credential with permission bitmap, bound to org (and optionally user/agent). Table: ibex_core.tokens.

Full schema reference: Data model.

Runtime binding rules

RuleEnforcement
Token org is authoritativeProxy middleware after ValidateToken
Agent must belong to token orgValidateAgent gRPC + store WHERE clause
Path org must match token org/v1/orgs/{org_id}/auth-probe only
Cross-tenant access403 — never 404

Chat completions use POST /v1/chat/completions with org from the token — there is no {org_id} path segment on chat. Diagnostic org probes exist to verify path binding for integrators building org-prefixed URLs in later phases.

Permission and agent headers

Every protected proxy request carries:

Authorization: Bearer ibex_pat_<uuid>_<secret>
X-IBEX-Agent-ID: <agent-uuid>

The agent UUID must reference an active row in ibex_core.agents where agents.org_id equals the token's org. Suspended agents return 403 AGENT_SUSPENDED.

Seed data for local dev

bash
make db-migrate
make db-seed
EntityFixed UUID (dev seed)
Organization00000000-0000-0000-0000-000000000001
Agent00000000-0000-0000-0000-000000000003
Token00000000-0000-0000-0000-000000000004

make db-seed exports IBEX_DEV_ORG_ID, IBEX_DEV_AGENT_ID, and IBEX_DEV_TOKEN for smoke tests. Seed refuses non-local DSN hosts and IBEX_ENV=production.

Projects (reserved)

The ibex_core schema includes hooks for project-scoped resources — memories, directives, and dashboard namespaces will attach to projects in Phase 3+. Phase 1 operators should:

  • Issue one PAT per integration environment (dev/staging/prod org)
  • Register one agent per autonomous service instance
  • Avoid assuming project IDs exist in API paths yet

Multi-tenant security layers

1

HTTP middleware

Proxy extracts org_id from validated token; rejects path mismatches.

2

gRPC handler

Auth validates org_id in CreateToken/ValidateAgent requests.

3

Store layer

Every query includes org_id in WHERE clauses.

4

Postgres RLS

Session org context gates row visibility — see Multi-tenant RLS.

Defense-in-depth rationale: Tenant isolation.

Verify org binding

bash
curl -s "http://localhost:8080/v1/orgs/${IBEX_DEV_ORG_ID}/auth-probe" \
  -H "Authorization: Bearer ${IBEX_DEV_TOKEN}" \
  -H "X-IBEX-Agent-ID: ${IBEX_DEV_AGENT_ID}"

CI security-integration runs automated cross-tenant cases — no manual probing required for merge gates.

Related

  • Multi-tenant RLS — database enforcement
  • Issuing API keys — PAT lifecycle
  • Proxy authentication — header contract
  • Concepts — integrator-oriented overview

Was this page helpful?

Edit on GitHub

Last updated on

PreviousIssuing API keysNextMulti-tenant RLS

On this page

  • Entity hierarchy
  • Runtime binding rules
  • Permission and agent headers
  • Seed data for local dev
  • Projects (reserved)
  • Multi-tenant security layers
  • Verify org binding
  • Related
0%