Skip to content

feat: the Discord bot token can live in the secrets proxy - #254

Merged
praxagent merged 1 commit into
mainfrom
feat/discord-via-proxy
Oct 3, 2026
Merged

praxagent merged 1 commit into
mainfrom
feat/discord-via-proxy

Conversation

@praxagent

Copy link
Copy Markdown
Owner

The Discord bot token was the one credential that couldn't move to the secrets proxy. Proxy side: praxagent/prax-secrets-proxy#8.

What was missed in July

The 2026-07-22 verdict (LOCAL: a 401, "no header to inject") came from header-only injection. The MITM forward proxy can do both remaining parts:

  • REST: inject Authorization: Bot <token> using a header prefix.
  • Gateway: rewrite the IDENTIFY and RESUME messages the client sends, setting d.token. discord.py sends them as plain JSON text: the gateway uses compress=0, and zlib-stream compresses only the server's side.

Changes

  • credential_registry: DISCORD_BOT_TOKEN is now PROXY_FORWARD, inject="discord-bot", exclusive=True.
    • The exported forward map includes Discord only when its caller is named: --exclusive-callers DISCORD_BOT_TOKEN=prax-prod.
    • Otherwise it is skipped, with the reason given. A dev Prax holding the placeholder can never become the bot too (Rule 0).
  • Tests: the registry tests cover exported-only-with-callers, the two rules, the prefix, and that only exclusive credentials carry callers.
  • Docs:
    • secrets-proxy.md gets a section with the rollout (the proxy holds the token, its own prax-prod caller, regenerate the map, Prax gets a placeholder plus DISCORD_USE_PROXY=true, then rotate the token);
    • credentials.md and deployment-topology.md are updated;
    • the VERIFICATION_LEDGER row is updated.

Verified

  • Live, with real discord.py 2.7.1 through the real mitmproxy against a fake Discord:
    • the named caller logged in, and its IDENTIFY carried the injected token;
    • another caller got 401 and LoginFailure.
    • Not run against Discord itself.
  • make ci green: 4013 passed. No secrets-proxy requests during the run beyond my own .invalid probe.

Rollout

This needs the proxy's #5, #6 and #8 merged and deployed, and production .env changes, which are yours to make. Steps are in the doc.

It stayed in Prax because REST wants 'Authorization: Bot <token>' and the
gateway carries the token inside IDENTIFY/RESUME. The forward proxy now does
both (header prefix + WebSocket message rewrite, prax-secrets-proxy #8). The
registry marks the credential exclusive: the forward map includes it only
with the one proxy caller allowed to run the bot (--exclusive-callers
DISCORD_BOT_TOKEN=prax-prod), so a dev instance can never become the bot too.
Verified with real discord.py through the real proxy against a fake Discord.
@praxagent
praxagent merged commit 3be897e into main Oct 3, 2026
1 check passed
@praxagent
praxagent deleted the feat/discord-via-proxy branch October 3, 2026 00:59
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.

1 participant