Skip to content
This repository was archived by the owner on Jul 4, 2026. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions hermes_cli/web_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,21 @@
app = FastAPI(title="Hermes Agent", version=__version__)

# ---------------------------------------------------------------------------
# Session token for protecting sensitive endpoints (reveal).
# Generated fresh on every server start — dies when the process exits.
# Injected into the SPA HTML so only the legitimate web UI can use it.
# Session token for protecting sensitive /api/* endpoints.
#
# By default, generated fresh on every server start and dies with the
# process — injected into the SPA HTML so the legitimate same-origin
# web UI picks it up without any external coordination. This is the
# single-user ``hermes web`` flow: one process, one SPA, same token.
#
# For reverse-proxied deployments where the UI lives on a different
# origin (e.g. a platform dashboard talking to many per-pod Hermes
# instances over the network), the downstream caller can't read the
# HTML injection, so it sets ``HERMES_SESSION_TOKEN`` to a stable
# value both sides share. Falls back to the random default when the
# env var is unset, preserving stand-alone CLI behavior.
# ---------------------------------------------------------------------------
_SESSION_TOKEN = secrets.token_urlsafe(32)
_SESSION_TOKEN = os.environ.get("HERMES_SESSION_TOKEN") or secrets.token_urlsafe(32)

# Simple rate limiter for the reveal endpoint
_reveal_timestamps: List[float] = []
Expand Down
Loading