caelum0x 8583f880df feat(rago): tenant bootstrap CLI and admin console API key management
- rago-worker create-org --name / create-api-key --org (id or slug): create
  an org + first key in one transaction, refuse taken slugs, print the key
  once as API_KEY=... (logs go to stderr for these subcommands)
- Admin console Operations > API keys: list live keys (masked), create,
  rotate and delete via the existing apiKeys/createApiKey/rotateApiKey/
  destroyApiKey GraphQL operations; new values shown once with copy; the
  console follows a rotation of its own key and blocks deleting the last key
- apiKeys no longer lists expired (rotated-out/destroyed) keys
- Tests: admin_cli unit tests + pg-tests suite for both subcommands;
  admin4 asserts rotated/destroyed keys drop out of apiKeys

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-25 04:15:23 +03:00

186 lines
11 KiB
HTML

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="robots" content="noindex" />
<title>Rago Billing</title>
<style>
:root {
--bg: #0f1117; --panel: #171a23; --panel2: #1c202b; --border: #272c39; --fg: #e6e8ee;
--muted: #8b91a1; --accent: #6ea8fe; --accent-fg: #0b1020; --danger: #f2668b;
--ok: #55c98a; --warn: #f0b95b; --row: #1e222d; --radius: 8px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
margin: 0; background: var(--bg); color: var(--fg);
font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
.icon { width: 16px; height: 16px; flex: none; vertical-align: -3px; }
input, button, select, textarea {
font: inherit; color: var(--fg); background: var(--row);
border: 1px solid var(--border); border-radius: 6px; padding: 7px 10px;
}
textarea { width: 100%; min-height: 90px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
input:focus, select:focus, textarea:focus, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
button { cursor: pointer; display: inline-flex; align-items: center; gap: 6px; }
button:disabled { opacity: .55; cursor: default; }
button.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); font-weight: 600; }
button.danger { color: var(--danger); border-color: #5a2a3a; }
button.ghost { background: transparent; }
a.btn { display: inline-flex; align-items: center; gap: 6px; color: var(--fg); background: var(--row); border: 1px solid var(--border); border-radius: 6px; padding: 7px 10px; }
a.btn.primary { background: var(--accent); color: var(--accent-fg); border-color: var(--accent); font-weight: 600; }
a.btn:hover { text-decoration: none; filter: brightness(1.1); }
button:hover:not(:disabled) { filter: brightness(1.1); }
.layout { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
aside {
background: var(--panel); border-right: 1px solid var(--border); padding: 14px 10px;
position: sticky; top: 0; height: 100vh; overflow-y: auto;
}
aside .brand { display: flex; align-items: center; gap: 8px; font-weight: 700; padding: 4px 10px 14px; letter-spacing: .3px; }
aside .group { color: var(--muted); font-size: 11px; text-transform: uppercase; letter-spacing: .6px; padding: 12px 10px 4px; }
aside a.nav {
display: flex; align-items: center; gap: 9px; padding: 7px 10px; border-radius: 6px;
color: var(--muted); text-decoration: none;
}
aside a.nav:hover { background: var(--row); color: var(--fg); }
aside a.nav.active { background: var(--panel2); color: var(--fg); border: 1px solid var(--border); }
.topbar {
display: flex; align-items: center; gap: 12px; padding: 12px 24px; border-bottom: 1px solid var(--border);
background: var(--panel); position: sticky; top: 0; z-index: 5;
}
.topbar .spacer { flex: 1; }
#status { font-size: 12px; color: var(--muted); }
#status.err { color: var(--danger); }
#status.ok { color: var(--ok); }
main { padding: 20px 24px 60px; max-width: 1400px; }
.page-head { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; flex-wrap: wrap; }
.page-head h2 { margin: 0; font-size: 20px; }
.page-head .sub { color: var(--muted); font-size: 13px; }
.page-head .spacer { flex: 1; }
.crumb { color: var(--muted); font-size: 13px; margin-bottom: 4px; }
.card { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: 16px; }
.card > h3 { margin: 0; padding: 12px 16px; font-size: 14px; border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 8px; }
.card > h3 .spacer { flex: 1; }
.card .body { padding: 14px 16px; }
.scroll { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 9px 14px; border-bottom: 1px solid var(--border); white-space: nowrap; font-variant-numeric: tabular-nums; }
th { color: var(--muted); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .5px; }
tbody tr.clickable { cursor: pointer; }
tbody tr:hover { background: var(--row); }
td.mono, .mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12.5px; }
td.num, th.num { text-align: right; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 20px; font-size: 12px; background: var(--row); border: 1px solid var(--border); }
.badge.ok { color: var(--ok); border-color: #1f4a35; }
.badge.err { color: var(--danger); border-color: #5a2a3a; }
.badge.warn { color: var(--warn); border-color: #5a4a22; }
.empty, .loading { padding: 28px; color: var(--muted); text-align: center; }
.error-box { padding: 14px 16px; color: var(--danger); }
.toolbar { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; padding: 10px 16px; border-bottom: 1px solid var(--border); }
.toolbar .spacer { flex: 1; }
.pager { display: flex; align-items: center; gap: 8px; padding: 10px 16px; color: var(--muted); font-size: 12.5px; }
.pager .spacer { flex: 1; }
.kv { display: grid; grid-template-columns: 180px 1fr; gap: 6px 16px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(420px, 1fr)); gap: 16px; }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 12px; margin-bottom: 16px; }
.kpi { background: var(--panel); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; }
.kpi .label { color: var(--muted); font-size: 12px; }
.kpi .value { font-size: 22px; font-weight: 650; margin-top: 4px; font-variant-numeric: tabular-nums; }
.kpi .hint { color: var(--muted); font-size: 12px; margin-top: 2px; }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 160px; padding: 10px 4px 0; }
.bars .bar { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 18px; }
.bars .fill { width: 100%; background: var(--accent); border-radius: 3px 3px 0 0; min-height: 1px; }
.bars .lbl { font-size: 10.5px; color: var(--muted); }
.actions { display: flex; gap: 8px; flex-wrap: wrap; }
.overlay { position: fixed; inset: 0; background: rgba(5, 7, 12, .66); display: flex; align-items: flex-start; justify-content: center; padding: 60px 16px; z-index: 50; overflow-y: auto; }
.modal { width: 100%; max-width: 620px; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; }
.modal header { display: flex; align-items: center; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal header h3 { margin: 0; font-size: 15px; flex: 1; }
.modal .content { padding: 16px 18px; display: grid; gap: 12px; }
.modal footer { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 18px; border-top: 1px solid var(--border); }
.field label { display: block; font-size: 12.5px; color: var(--muted); margin-bottom: 4px; }
.field input, .field select { width: 100%; }
.field .help { font-size: 12px; color: var(--muted); margin-top: 3px; }
.field.check label { display: flex; align-items: center; gap: 8px; color: var(--fg); }
.field.check input { width: auto; }
.form-error { color: var(--danger); font-size: 13px; white-space: pre-wrap; }
.toast-wrap { position: fixed; right: 18px; bottom: 18px; display: grid; gap: 8px; z-index: 60; }
.toast { background: var(--panel2); border: 1px solid var(--border); border-radius: 8px; padding: 10px 14px; max-width: 420px; display: flex; gap: 8px; align-items: flex-start; }
.toast.err { border-color: #5a2a3a; }
.toast.ok { border-color: #1f4a35; }
pre.json { margin: 0; padding: 12px 16px; overflow: auto; max-height: 360px; font-size: 12px; background: var(--row); border-radius: 6px; }
.gate { max-width: 460px; margin: 12vh auto; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: 26px; }
.gate h1 { margin: 0 0 6px; font-size: 20px; display: flex; gap: 8px; align-items: center; }
.gate p { color: var(--muted); margin: 0 0 16px; }
.gate input { width: 100%; margin-bottom: 10px; }
.gate button { width: 100%; justify-content: center; }
.gate-divider { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 12px; margin: 16px 0; }
.gate-divider::before, .gate-divider::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.muted { color: var(--muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
code { background: var(--row); padding: 1px 5px; border-radius: 4px; font-size: 12px; }
@media (max-width: 860px) {
.layout { grid-template-columns: 1fr; }
aside { position: static; height: auto; }
.kv { grid-template-columns: 1fr; }
}
</style>
</head>
<body>
<div id="gate" class="gate" style="display:none">
<h1 id="gate-title">Rago Billing</h1>
<p>Sign in with an organization API key. Every request is sent as
<code>Authorization: Bearer &lt;key&gt;</code> to this Rago server's API.</p>
<form id="gate-form">
<label for="key" class="sr">API key</label>
<input id="key" type="password" placeholder="Organization API key" autocomplete="off" required />
<button class="primary" type="submit">Connect</button>
<div id="gate-error" class="form-error" role="alert"></div>
</form>
<div class="gate-divider"><span>or</span></div>
<form id="sso-form">
<label for="sso-email" class="sr">Work email</label>
<input id="sso-email" type="email" placeholder="Work email for single sign-on" autocomplete="email" />
<button type="submit">Sign in with SSO</button>
<div id="sso-error" class="form-error" role="alert"></div>
</form>
</div>
<div id="app" class="layout" style="display:none">
<aside>
<div class="brand" id="brand"></div>
<nav id="nav" aria-label="Sections"></nav>
</aside>
<div>
<div class="topbar">
<span id="org-name" class="mono"></span>
<div class="spacer"></div>
<span id="status" role="status"></span>
<button id="logout" class="ghost" type="button"></button>
</div>
<main id="view" tabindex="-1"></main>
</div>
</div>
<div id="overlay-root"></div>
<div class="toast-wrap" id="toasts" aria-live="polite"></div>
<script src="/admin/core.js"></script>
<script src="/admin/billing.js"></script>
<script src="/admin/views.js"></script>
<script src="/admin/quotes.js"></script>
<script src="/admin/integrations.js"></script>
<script src="/admin/keys.js"></script>
<script src="/admin/views2.js"></script>
</body>
</html>