fix(config): refuse a token over non-loopback http on every config request #606

Merged
hexajon merged 2 commits from fix/scheme-check-authed-request into main 2026-09-23 15:28:29 +00:00
Owner

Summary

doAuthedRequest now runs RequireSecureScheme before it attaches the token, so every token-bearing request in internal/config refuses a non-loopback http:// URL. The environment rung of GetCredentialsWithSource skipped the check, so auth whoami sent an env token over cleartext. Token-less requests, https, and loopback http still go out. A test proves the refusal comes before any request is sent, and it fails with the guard removed.

The refusal text named gitea.url, a key madtea does not read. It now names MADTEA_URL and madtea.url.

ADR 0041 records the rule: no token over non-loopback http, no opt-out, loopback exempt.

Closes #605

Closes #605

## Summary `doAuthedRequest` now runs `RequireSecureScheme` before it attaches the token, so every token-bearing request in `internal/config` refuses a non-loopback `http://` URL. The environment rung of `GetCredentialsWithSource` skipped the check, so `auth whoami` sent an env token over cleartext. Token-less requests, `https`, and loopback `http` still go out. A test proves the refusal comes before any request is sent, and it fails with the guard removed. The refusal text named `gitea.url`, a key madtea does not read. It now names `MADTEA_URL` and `madtea.url`. ADR 0041 records the rule: no token over non-loopback http, no opt-out, loopback exempt. Closes #605 Closes #605
doAuthedRequest now runs RequireSecureScheme before it attaches the token.
The env rung of GetCredentialsWithSource skipped that check, so auth whoami
sent an env token to a non-loopback http URL.

The refusal also named gitea.url, a key madtea does not read. It now names
MADTEA_URL and madtea.url.
fix(config): refuse a token over non-loopback http on every config request
All checks were successful
ci / mcp-conformance (pull_request) Successful in 1m57s
drift / govulncheck (pull_request) Has been skipped
drift / surface-diff (pull_request) Successful in 1m14s
drift / forgejo-smoke (pull_request) Has been skipped
ci / mcp-conformance (push) Successful in 2s
drift / govulncheck (push) Has been skipped
drift / surface-diff (push) Successful in -4s
drift / forgejo-smoke (push) Has been skipped
ci / gate (push) Successful in 17m12s
ci / gate (pull_request) Successful in 30m19s
0dab4ac758
Closes #605
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
sixfold-space/madtea!606
No description provided.