Skip to content

Separate the admin account from inference API keys - #102

Merged
maiphucgiang merged 1 commit into
mainfrom
feature/admin-account-api-keys
Oct 29, 2026
Merged

maiphucgiang merged 1 commit into
mainfrom
feature/admin-account-api-keys

Conversation

@maiphucgiang

@maiphucgiang maiphucgiang commented Oct 29, 2026 •

Copy link
Copy Markdown
Owner

Summary

  • WebUI management now signs in with an admin username and a scrypt-hashed password instead of the shared API key. A normal session lasts 12 hours; Remember me lasts 400 days with sliding renewal. Changing the username or password (Settings → Admin account) verifies the current password, revokes other sessions and returns a fresh CSRF token; every session can also be revoked at once.
  • Startup migrates existing installs atomically: the legacy default key becomes the admin password and a hashed database admin key, so existing clients keep working. An external CODEBUDDY2API_KEY stays an inference-only admin key and doubles as the initial password until it is changed. Without one, startup prints a random initial password and creates no inference key.
  • New Keys page and /admin/keys API. At most one database admin key (unrestricted, shown only at creation or rotation, hash stored), plus standard keys with name, enable/disable, expiry, IP/CIDR allowlist, RPM and model restrictions, rotation, reveal, copy and deletion. Standard keys are stored in plaintext in control.sqlite3 and backups, which the docs and .env.example now call out.
  • Credentials are kept apart: API keys authorize only /v1/*, and the management Cookie authorizes only /admin/*. Standard keys cannot read account-pool billing or poll another key's video tasks. Any key row, even a disabled or expired one, turns off CODEBUDDY2API_ALLOW_OPEN_NOAUTH.
  • Audit rows record the calling key. Logs filter by key and show <id> (deleted) or — (pre-upgrade) for older rows, and the Keys table shows approximate 24-hour requests and last use. Clearing all logs and statistics now re-confirms with the management password.
  • converter.py admin reset-password [--username NAME] resets the account from a TTY, even while the server runs. Config migration moves to schema v3 and carries api_keys. The preview signs in as admin / preview and seeds sample restricted keys.
  • The login page, initial-password banner, Admin account tab and Keys page follow the existing glass panel, table and drawer conventions. English and Chinese README and docs are updated together, and AGENTS.md lists the new subcommand.

#101

- WebUI sign-in uses an admin username and scrypt-hashed password;
  sessions last 12 hours or 400 days with "remember me", and account
  changes revoke other sessions and return a fresh CSRF token
- Startup migrates the legacy default key into the admin password and
  a hashed admin API key; without CODEBUDDY2API_KEY it prints a random
  initial password and creates no inference key
- New Keys page and /admin/keys API: one hashed admin key plus standard
  keys with expiry, IP/CIDR allowlists, RPM and model limits, rotation,
  reveal and copy
- API keys authorize only /v1/*, the management Cookie only /admin/*;
  standard keys cannot read account-pool billing or other keys' video
  tasks, and any key row disables open no-auth mode
- Audit rows record the calling key: logs filter by key and the Keys
  table shows 24-hour requests and last use; clearing all logs now
  re-confirms with the management password
- `converter.py admin reset-password` resets the account from a TTY;
  config migration moves to v3 and carries api_keys
- Settings gains an Admin account tab, the login page asks for a
  username and password, preview seeds sample keys, and the English
  and Chinese docs cover the new model
@sourcery-ai

sourcery-ai Bot commented Oct 29, 2026

Copy link
Copy Markdown

Sorry @maiphucgiang, your pull request is larger than the review limit of 150,000 diff characters

Comment thread app/api_keys.py Dismissed
Comment thread app/startup.py Dismissed
@maiphucgiang
maiphucgiang merged commit 2fa9b7c into main Oct 29, 2026
9 checks passed
@maiphucgiang
maiphucgiang deleted the feature/admin-account-api-keys branch October 29, 2026 05:22
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.

2 participants