Skip to content

Latest commit

 

History

History
84 lines (64 loc) · 4.05 KB

ADMIN-UI.md

File metadata and controls

84 lines (64 loc) · 4.05 KB

Admin UI

There is no UI in this repository: the gateway is a single Java process and stays that way. The admin console lives in its own repository, an1ndra/path-admin (Vite + React, served as static files). The README carries four screenshots of it against example data.

What it covers

Read and write against this API: dashboard (spend, cache, latency, provider circuits, top models, recent failures), usage (filter by key/end user/window, page through rows, export CSV), audit (every admin write, filterable by action), IP access (allow/deny CIDR rules and the addresses seen, with country and user agent), security (recent calls with key, client IP, user agent and request id), end users (aggregate spend and blocking), providers (create/edit with a provider API key, probe, delete), routes (add a model, enable/disable, delete), client keys (create with budgets and allowlists, top up, revoke), configuration (the gateway switches, the default system prompt, alert email and the daily digest) and settings (the session: identity, scopes, token, sign out). The sidebar language selector switches the console between English, Hindi, Bengali, Chinese, Korean and Japanese and remembers the choice per browser; the Configuration prompt editor stores the matching variants selected by Accept-Language.

Auth

The console signs in with a username/password account or GitHub OAuth and keeps the resulting session token in sessionStorage. The first visit shows a setup form that creates the owner; later users are managed on the Users page with owner, admin or viewer roles. X-Admin-Token remains supported for automation and bootstrap, but the console no longer asks for it.

GitHub login needs an OAuth app whose callback is https://<gateway>/admin/auth/github/callback; set GATEWAY_GITHUB_CLIENT_ID, GATEWAY_GITHUB_CLIENT_SECRET, GATEWAY_GITHUB_REDIRECT_URI and GATEWAY_GITHUB_CONSOLE_URL. GATEWAY_GITHUB_ALLOWED_USERS limits which GitHub logins may create an account.

curl -X POST http://localhost:8080/admin/tokens \
  -H "X-Admin-Token: $GATEWAY_ADMIN_TOKEN" -H 'Content-Type: application/json' \
  -d '{"name":"anindra-laptop","scopes":"read,write"}'

scopes is read or read,write. Revoke with POST /admin/tokens/{id}/revoke. Every admin write is recorded in GET /admin/audit.

GET /admin/settings reports the caller's own scopes so the console can adapt instead of discovering a restriction through a failed write:

{"auth_mode": "token", "subject": "anindra-laptop", "scopes": ["read"], "can_write": false}

subject is the token name, or the SSO identity in proxy mode. The console hides (or disables with a tooltip) every create, edit, delete and revoke control when scopes does not contain write, and shows a "read-only token" badge. Neither value is a credential.

Single sign-on

SSO, 2FA and passkeys are delegated to an authenticating proxy — Authentik, Keycloak, oauth2-proxy or Cloudflare Access — which injects an identity header the gateway trusts. See SSO.md; the console detects that mode and skips its token screen.

Hosting it

Two shapes, and the choice decides whether you need CORS:

Shape Gateway setting
Same hostname — proxy /admin-ui/* to the UI and everything else to the gateway nothing
Separate hostname — admin.example.com → UI, gw.example.com → gateway GATEWAY_CORS_ORIGINS=https://admin.example.com

The console needs X-Admin-Token to pass through the preflight; the default CORS mapping already allows * headers and the admin methods, and it must not enable credentials because the token is a header, not a cookie.

Do not expose /admin/** to the internet without something in front of it — Cloudflare Access, a VPN, or an IP allowlist. The admin auth limiter (10 failures / 5 min) is a backstop, not an access control.

Related