Skip to content

Cockpit login + Databento-style trading tokens - #21

Merged
maxkuttner merged 3 commits into
mainfrom
feat/cockpit-auth-tokens
Jul 27, 2026
Merged

Cockpit login + Databento-style trading tokens#21
maxkuttner merged 3 commits into
mainfrom
feat/cockpit-auth-tokens

Conversation

@maxkuttner

Copy link
Copy Markdown
Owner

Summary

Adds a real cockpit login and a single-bearer trading token system for API clients / bots.

Auth

  • Trading routes now accept a single Authorization: Bearer <key_id>.<secret> token alongside the existing Basic key_id:secret (back-compat kept). Shared verify_key helper in auth.rs.
  • Cockpit is gated by a login screen using the admin password (OMS_ADMIN_PASSWORD, falls back to OMS_ADMIN_TOKEN); logout + auto-redirect on 401/403.

Trading tokens (token-per-principal)

  • POST/GET/DELETE /admin/trading-tokens — mint a single-bearer token under an existing principal (optionally granting a portfolio in the same call), list, revoke. Tokens are api_keys; grants live on the principal so many tokens rotate freely.
  • Matches how Databento/Binance/Alpaca work: identity is durable, tokens are rotatable credentials.

Cockpit

  • New API tab (/tokens) styled to the openOMS terminal identity: terminal-readout credential reveal (copy-once + ready curl) and a mono token ledger with revoke.
  • Rebranded login screen (depth-ladder accent, mono, admin password).

Verification

  • Live e2e against Binance FIX testnet earlier; bearer token places orders, bad/revoked token → 401, Basic back-compat intact.
  • cargo test 113 pass; cockpit tsc + vite build clean.

Notes

  • OMS_ADMIN_AUTH_ENABLED=true enables the login gate; OMS_ADMIN_PASSWORD is the console password.
  • Principals are created on the Principals tab; the API tab only mints tokens for existing ones.

Max added 3 commits July 27, 2026 16:22
Backend:
- auth_middleware accepts a single bearer trading token (key_id.secret)
  alongside the existing Basic key_id:secret; shared verify_key helper.
- POST/GET/DELETE /admin/trading-tokens: mint a token under a principal
  (existing or quick-created), optionally granting a portfolio. Tokens are
  api_keys; grants stay on the principal so many tokens rotate freely.
- Admin console password read from OMS_ADMIN_PASSWORD (OMS_ADMIN_TOKEN
  still accepted as fallback).

Cockpit:
- Login gate + branded sign-in screen (admin password); logout; client
  clears the token and returns to login on 401/403.
- New 'API' tab (route /tokens): create/list/revoke tokens, styled to the
  openOMS terminal identity with a terminal-readout credential reveal.
- Retired the old Trading tokens page.
Drop the quick-create-principal path from the token flow (backend + UI).
Principals are created on the Principals tab; the API tab just mints tokens
for an existing one — clearer separation, no stray service principals.
@maxkuttner
maxkuttner merged commit 16be101 into main Jul 27, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant