360 Secure SkillHub
360 安全技能中心

omni-auth

该 Skill 是 OmniRoute 认证接口参考,提供管理密码登录、会话 Cookie、CSRF、MFA 设置/验证/关闭、登出及 OIDC 登录回调的 curl 示例;需连接可用的 OmniRoute 服务,实际响应与认证策略由服务端决定。

分类:安全
cheaper-inference
热度 0.00
最近更新 2026-11-20 05:10:16

安装

发给 Agent
帮我安装这个技能:npx secure-skills-cli add cheaper-inference/omniroute/omni-auth
兼容性
通用兼容
联网要求
需要联网
数据出网
必须出网
Metadata
name
omni-auth
description
Manage API key authentication and session tokens. Start here to authenticate requests via Bearer token, obtain session cookies, and configure login requirements for the OmniRoute API.

Overview

Manage API key authentication and session tokens. Start here to authenticate requests via Bearer token, obtain session cookies, and configure login requirements for the OmniRoute API.

Authentication

Remote API requests use a Bearer credential. Dashboard login is different: POST /api/auth/login accepts a management password and returns an auth_token session cookie.

Endpoints

POST /api/auth/login

Authenticate user

curl -X POST http://localhost:20128/api/auth/login \
  -H "Content-Type: application/json" \
  -c cookie.jar \
  -d '{"password":"<management-password>"}'

POST /api/auth/mfa/verify

Complete a two-factor sign-in

Login step 2 (public). Trades the MFA-pending cookie set by /api/auth/login plus a TOTP or recovery code for the dashboard session cookie. Shares the login brute-force lockout; a TOTP step and a recovery code are each accepted once.

CSRF_TOKEN=$(curl -s http://localhost:20128/api/auth/csrf -b cookie.jar | jq -r .token)
curl -X POST http://localhost:20128/api/auth/mfa/verify \
  -b cookie.jar \
  -H "x-omniroute-csrf: $CSRF_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{}'

GET /api/auth/mfa/status

Two-factor authentication status

curl http://localhost:20128/api/auth/mfa/status \
  -b cookie.jar

POST /api/auth/mfa/setup

Start two-factor enrollment

Re-authenticates with the current password and returns a candidate TOTP secret, its otpauth:// URI and a QR code (PNG data URI). Nothing is persisted.

CSRF_TOKEN=$(curl -s http://localhost:20128/api/auth/csrf -b cookie.jar | jq -r .token)
curl -X POST http://localhost:20128/api/auth/mfa/setup \
  -b cookie.jar \
  -H "x-omniroute-csrf: $CSRF_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{}'

POST /api/auth/mfa/enable

Finish two-factor enrollment

Persists the secret (encrypted at rest) once the current password and a code generated from it both verify. Returns ten single-use recovery codes, shown once.

CSRF_TOKEN=$(curl -s http://localhost:20128/api/auth/csrf -b cookie.jar | jq -r .token)
curl -X POST http://localhost:20128/api/auth/mfa/enable \
  -b cookie.jar \
  -H "x-omniroute-csrf: $CSRF_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{}'

POST /api/auth/mfa/disable

Turn two-factor authentication off

Requires the current password and a live TOTP or recovery code. While OMNIROUTE_DISABLE_MFA=true is set, a request from the host itself (loopback peer and loopback Host) may omit code to remove a factor that can no longer be verified; the session and password are still required.

CSRF_TOKEN=$(curl -s http://localhost:20128/api/auth/csrf -b cookie.jar | jq -r .token)
curl -X POST http://localhost:20128/api/auth/mfa/disable \
  -b cookie.jar \
  -H "x-omniroute-csrf: $CSRF_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{}'

POST /api/auth/logout

Log out

CSRF_TOKEN=$(curl -s http://localhost:20128/api/auth/csrf -b cookie.jar | jq -r .token)
curl -X POST http://localhost:20128/api/auth/logout \
  -b cookie.jar \
  -H "x-omniroute-csrf: $CSRF_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{}'

GET /api/auth/oidc/login

Start OIDC login for the dashboard admin gate

Builds an authorization URL from the configured OIDC issuer/client (discovered via {issuer}/.well-known/openid-configuration, falling back to {issuer}/authorize), sets a short-lived oidc_state cookie, and redirects the browser. Password login remains available as a fallback while OIDC is enabled.

curl http://localhost:20128/api/auth/oidc/login \
  -b cookie.jar

GET /api/auth/oidc/callback

Complete OIDC login for the dashboard admin gate

Validates the state cookie, exchanges the authorization code for tokens, verifies the ID token against the issuer's JWKS (audience = client id), and requires at least one dashboard admission policy: oidcAllowedSubjects (matching sub or verified email) or oidcAdmissionClaim (matching a configured array claim in the verified ID token). When both are present, both must match. Without either policy the callback returns not_configured. On success it mints the same 30-day auth_token dashboard-session JWT used by password login and redirects to /dashboard.

curl http://localhost:20128/api/auth/oidc/callback \
  -b cookie.jar

GET /api/auth/csrf

GET auth › csrf

curl http://localhost:20128/api/auth/csrf \
  -b cookie.jar

GET /api/auth/status

GET auth › status

curl http://localhost:20128/api/auth/status \
  -b cookie.jar

Payloads

See the full OpenAPI specification at GET /api/openapi/spec or docs/openapi.yaml for detailed request/response schemas.

OmniRoute

Local/remote AI gateway exposing OpenAI-compatible REST. One key, hundreds of providers, auto-fallback, RTK token saver, MCP server, A2A agents.

Setup

export OMNIROUTE_URL="http://localhost:20128"      # or VPS / tunnel URL
export OMNIROUTE_KEY="sk-..."                       # from Dashboard → API Keys

All requests: ${OMNIROUTE_URL}/v1/... with Authorization: Bearer ${OMNIROUTE_KEY}.

Verify: curl $OMNIROUTE_URL/api/health → {"status":"ok","timestamp":"..."}

Discover models

curl $OMNIROUTE_URL/v1/models                  # chat/LLM (default)
curl "$OMNIROUTE_URL/v1/models?kind=image"     # image-gen
curl "$OMNIROUTE_URL/v1/models?kind=audio"     # text-to-speech + speech-to-text
curl "$OMNIROUTE_URL/v1/models?kind=embedding" # embeddings
curl $OMNIROUTE_URL/v1/search                  # web search providers

Use data[].id as model field in requests. Combos appear with owned_by:"combo".

Capability skills

Capability Raw URL
Chat / code-gen https://raw.githubusercontent.com/cheaper-inference/OmniRoute/main/skills/omni-inference/SKILL.md
Image generation https://raw.githubusercontent.com/cheaper-inference/OmniRoute/main/skills/omni-inference/SKILL.md
Text-to-speech https://raw.githubusercontent.com/cheaper-inference/OmniRoute/main/skills/omni-inference/SKILL.md
Speech-to-text https://raw.githubusercontent.com/cheaper-inference/OmniRoute/main/skills/omni-inference/SKILL.md
Embeddings https://raw.githubusercontent.com/cheaper-inference/OmniRoute/main/skills/omni-inference/SKILL.md
Web search https://raw.githubusercontent.com/cheaper-inference/OmniRoute/main/skills/omni-inference/SKILL.md
Web fetch https://raw.githubusercontent.com/cheaper-inference/OmniRoute/main/skills/omni-inference/SKILL.md
MCP server https://raw.githubusercontent.com/cheaper-inference/OmniRoute/main/skills/omni-mcp/SKILL.md
A2A protocol https://raw.githubusercontent.com/cheaper-inference/OmniRoute/main/skills/omni-agents-a2a/SKILL.md
Routing & combos https://raw.githubusercontent.com/cheaper-inference/OmniRoute/main/skills/omni-combos-routing/SKILL.md
Token compression https://raw.githubusercontent.com/cheaper-inference/OmniRoute/main/skills/omni-compression/SKILL.md
Monitoring & health https://raw.githubusercontent.com/cheaper-inference/OmniRoute/main/skills/omni-resilience/SKILL.md

CLI skills (omniroute binary)

Capability Raw URL
CLI entry point https://raw.githubusercontent.com/cheaper-inference/OmniRoute/main/skills/cli-serve/SKILL.md
CLI admin & lifecycle https://raw.githubusercontent.com/cheaper-inference/OmniRoute/main/skills/cli-serve/SKILL.md
CLI providers & keys https://raw.githubusercontent.com/cheaper-inference/OmniRoute/main/skills/cli-providers/SKILL.md
CLI cloud agents (omniroute cloud …) https://raw.githubusercontent.com/cheaper-inference/OmniRoute/main/skills/cli-backup-sync/SKILL.md
CLI evals & benchmarks https://raw.githubusercontent.com/cheaper-inference/OmniRoute/main/skills/cli-eval/SKILL.md

Errors

  • 401 → set/refresh OMNIROUTE_KEY (Dashboard → API Keys)
  • 400 Invalid model format → check model exists in /v1/models
  • 503 provider_circuit_open → upstream provider down; retry after Retry-After seconds
  • 429 → rate limited; honor Retry-After

Differentiators vs OpenAI direct

  • Auto-fallback combos (every routing strategy): never stop coding even if a provider rate-limits
  • RTK token saver: tool_result compressed via 47 specialized filters (git-diff, test-jest, terraform-plan, docker-logs…) — 20-40% token reduction
  • Caveman mode: optional terse system prompt injection (LITE/FULL/ULTRA) — 15-25% completion reduction
  • MCP + A2A servers built-in (this is the only AI router that exposes both protocols)
  • Memory with FTS5 + Qdrant for persistent agent context
  • Guardrails for PII masking, prompt injection detection, vision policies