fix(github): pin OAuth redirect_uri to decocms.com allowlist
Merged
0X
5mo ago+139+139+012345678901234567890123456789-0-0-0123456789
authorizationUrl() forwarded the runtime-supplied callback URL verbatim as GitHub's redirect_uri. GitHub delivers the authorization code to that host, so an attacker-influenced origin (spoofed Host header, injected redirect param, misconfigured route) would hijack the code and the token minted from it in exchangeCode.
Add an allowlist validator that refuses any redirect_uri whose host is not decocms.com or a subdomain (https; http allowed only for loopback dev per RFC 8252), and call it before the value reaches GitHub.
Summary by cubic
Pin GitHub OAuth redirect_uri to the decocms.com allowlist to block code/token hijacking. Enforces https for production and allows http only on loopback hosts for local dev (RFC 8252).
- Bug Fixes
- Added
isAllowedRedirectUri/assertAllowedRedirectUriwithALLOWED_REDIRECT_HOST_SUFFIXES = ["decocms.com"]. - Require https for
decocms.comand subdomains; allow http only for loopback hosts (localhost, 127.0.0.1, ::1/[::1]). - Validate
redirect_uribefore sending to GitHub; tests cover canonical, subdomains, loopback vs non-loopback http, suffix-confusion, case-insensitive hosts, and malformed schemes/URLs.
- Added