Implements the account and user-management system behind the new web UI against development repositories only. Nothing here connects to, reads, or modifies the production umbracontrol database, and no account is created in any approved environment. Account service and API: - Local temporary-password and OIDC enrollment, separated by type. - Argon2id credentials, must-change enforcement, server-side sessions with hashed tokens, idle and absolute deadlines, rotation and revocation. - Administrator account management: list, get, create, suspend, reactivate, deactivate, revoke sessions, org-scoped audit view. - Hidden-prompt operator command for the first administrator, refusing production mode and refusing to run without a TTY. Temporary passwords are never accepted from a client. The request schema has no password field and refuses unknown fields; the administrator path generates the one-time password in process, hashes it immediately, and returns it once in the creation response. The account can reach no route, including /api/auth/me, until it replaces that password, after which the one-time value no longer authenticates. Security posture: fail-closed configuration, Secure cookies in production, double-submit CSRF, constant-time token comparison, generic authentication errors, audit detail allow-listing, and logger-tree secret redaction. Reviewed but unapplied: migrations/0001_phase1_identity.sql adds users.username, a separate user_credentials table, and additive session columns, with a rollback and open review questions. The PostgreSQL adapter is deliberately absent, so the application refuses to start in production rather than run against an unreviewed store. Verification: 169 tests pass (148 new, 21 pre-existing); ruff check, ruff format, compileall, and make web-check are clean.
37 lines
1.1 KiB
Python
37 lines
1.1 KiB
Python
"""Module entry point: ``python -m umbratrans_web <command>``.
|
|
|
|
``bootstrap-admin`` is the hidden-prompt operator command and is also installed
|
|
as the ``umbratrans-bootstrap-admin`` console script. ``serve`` runs the
|
|
development API on the loopback interface.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
import sys
|
|
from collections.abc import Sequence
|
|
|
|
from .cli import bootstrap_admin, serve
|
|
|
|
COMMANDS = {
|
|
"bootstrap-admin": bootstrap_admin,
|
|
"serve": serve,
|
|
}
|
|
|
|
|
|
def main(argv: Sequence[str] | None = None) -> int:
|
|
args = list(argv) if argv is not None else sys.argv[1:]
|
|
if not args or args[0] in {"-h", "--help"}:
|
|
print("usage: python -m umbratrans_web {" + ",".join(sorted(COMMANDS)) + "}", file=sys.stderr)
|
|
print("See each command's --help output. No command accepts a password argument.", file=sys.stderr)
|
|
return 0
|
|
command, rest = args[0], args[1:]
|
|
handler = COMMANDS.get(command)
|
|
if handler is None:
|
|
print(f"unknown command: {command}", file=sys.stderr)
|
|
return 2
|
|
return handler(rest)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
raise SystemExit(main())
|