3 Admin Routes Reference
vBlackOut edited this page 2026-08-26 07:48:04 +02:00

Admin Routes Reference

This page documents every /adm/* HTTP endpoint ProxyAuth exposes for operators — stats, log inspection, session revocation, and OTP reset. All of them (except where noted) are protected the same way: a required X-Auth-Token header matching config.json's token_admin, checked with a constant-time comparison.

⚠️ None of these routes are currently rate-limited. They're gated only by token_admin. Treat that token like a root credential, and keep it out of logs, URLs, and version control.


Authentication

Every route below expects:

X-Auth-Token: <token_admin from config.json>

Missing or incorrect token → 401 Unauthorized. If token_admin is empty/unset in config.json, every admin route is permanently locked out (an empty admin token is never treated as valid).


GET /adm/stats

Live request-rate and session metrics for this instance.

Requires: stats: true in config.json — if disabled, this still requires a valid admin token but returns the metrics regardless (the stats flag only gates the underlying per-token usage tracking used by /adm/stats/sessions, not this endpoint's own counters).

Response:

{
  "requests_per_second": 42,
  "avg_rps_10s": 39.5,
  "avg_rps_60s": 35.1,
  "total_requests": 1928374,
  "uptime_seconds": 86412,
  "active_sessions": 57
}

These numbers are per-instance, in-memory only — they reset on restart and aren't shared across a multi-instance deployment. Query each instance individually if you need cluster-wide totals.


GET /adm/stats/sessions

Per-user, per-token usage detail — how many times each issued token has been used, and when it was delivered/expires.

Requires: stats: true in config.json.

Response:

[
  {
    "user": "alice",
    "tokens": [
      {
        "token_id": "a1b2c3...",
        "count": 14,
        "delivery_at": "2026-08-13 09:12:03",
        "expire_at": "2026-08-13 10:12:03"
      }
    ]
  }
]

Timestamps are formatted in the timezone set by config.json's timezone field.


GET /adm/logs

Returns the in-memory application log buffer as plain text.

Response: Content-Type: text/plain, the most recent log lines (newest logs appended at the end), one per line.

The buffer now receives an access-log line for every request, not just the subset that used to be logged — see Logging. At any real traffic level a 1000-line buffer may hold only a few seconds of history. Raise write_max_logs, or silence high-volume routes with logging.routes / log: false.

Buffer size is controlled by log.write_max_logs in config.json (default 1000) — once full, the oldest line is dropped as new ones arrive. This is a ring buffer held in memory, not a file on disk; restarting the service clears it. If you need durable/searchable logs, configure log.type: "loki" instead (see the config.json Reference) and query Loki directly rather than this endpoint.


POST /adm/revoke

Revokes a session token, so it's rejected on its next use regardless of its original expiry.

Body:

{
  "token_id": "a1b2c3...",
  "exp": 1755100000
}
Field Type Required Meaning
token_id string yes The token identifier to revoke (the token_id shown in /adm/stats/sessions, or the value logged at login/validation time).
exp integer (unix timestamp), or omitted no If set, the revocation entry itself expires at this time (useful for temporary bans). If omitted, the token is revoked permanently — it will never validate again, even after what would have been its natural expiry.

Response: 200 OK with a short confirmation message ("Token revoked with expiration." or "Token permanently revoked."), or 500 if the revocation backend (see Token Revocation & Multi-Instance Sync) couldn't be written to.

This is the same underlying mechanism used automatically by /logout (see the logout fix note in the changelog) — you don't need to call this manually for a user's own logout, only for admin-initiated revocation (compromised token, offboarding a user immediately, etc.).


POST /adm/auth/totp/reset

Clears a user's TOTP secret so they can re-enroll. Covered in detail in TOTP (2FA) Enrollment & Reset — Admin Guide — included here for completeness of the /adm/* surface.

curl -X POST https://proxy.example.com/adm/auth/totp/reset \
  -H "X-Auth-Token: $ADMIN_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{"username": "alice"}'

Quick reference

Route Method Requires stats: true? Purpose
/adm/stats GET No Live request-rate metrics
/adm/stats/sessions GET Yes Per-user token usage detail
/adm/logs GET No In-memory log buffer
/adm/revoke POST No Revoke a session token
/adm/auth/totp/reset POST No Clear a user's OTP secret

See also