Skip to content

Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors

1.1 KB
Raw Blame
%% AuthZ pipeline (3 route classes + policy evaluation)
%% Reflects: src/middleware.ts, src/server/authz/pipeline.ts,
%%           src/server/authz/policies/{public,clientApi,management}.ts
%% v3.8.0
flowchart LR
  Req["Incoming request"] --> Strip["Strip trusted internal headers<br/>(x-omniroute-auth-*)"]
  Strip --> Classify["classifyRoute()"]
  Classify -->|PUBLIC| PubP["publicPolicy<br/>(login, health, status)"]
  Classify -->|CLIENT_API| CliP["clientApiPolicy<br/>(/api/v1/*, /v1/*)"]
  Classify -->|MANAGEMENT| MgmtP["managementPolicy<br/>(dashboard, settings, admin)"]

  PubP -->|allow| Stamp["Stamp x-omniroute-auth-*<br/>(kind / id / label / scopes)"]
  CliP -->|extract Bearer| Validate["validateApiKey()"]
  Validate -->|valid| Stamp
  Validate -->|"invalid (REQUIRE_API_KEY=true)"| Reject401["401 AUTH_002"]
  Validate -->|"absent (REQUIRE_API_KEY=false)"| Anon["anonymous fallthrough"] --> Stamp

  MgmtP -->|session ok| Stamp
  MgmtP -->|Bearer w/ manage scope| Stamp
  MgmtP -->|"Bearer invalid"| Reject403["403 AUTH_001"]
  MgmtP -->|no auth| Reject401Mgmt["401 / 302 /login"]

  Stamp --> Handler["Handler<br/>(uses assertAuth)"]