v0.63.0
What's Changed
HTTP — CORS origin allowlist (breaking for credentialed browser clients)
Require explicit Origins for credentialed CORS responses
SetAccessControlAllowHeaders(and thereforeAddCORSHandler/Wrap) previously reflected anyhttps://Origin withAccess-Control-Allow-Credentials: true(and allowedCookie/X-User-Id). That allowed arbitrary HTTPS sites to make credentialed cross-origin calls.- Origins must now be listed in
MOOV_CORS_ALLOW_ORIGINS(comma-separated exact Origins), e.g.https://moov.io,https://dashboard.moov.io. - Loopback HTTP origins remain allowed for local development:
http://localhost,http://localhost:<port>,http://127.0.0.1,http://127.0.0.1:<port>. - Unlisted Origins receive no
Access-Control-Allow-Origin/ credentials headers. - Allowed responses also set
Vary: Origin.
Reusable API for services
- Services that already call
AddCORSHandler,SetAccessControlAllowHeaders, orWrappick this up by bumpingmoov-io/base— no local CORS forks required. SetCORSAllowedOrigins([]string)— programmatic / config-driven allowlist (safe concurrent with request handlers).OriginAllowedForCORS(origin string) bool— shared check for custom handlers (e.g. go-kitServerAfter).ResetCORSAllowlistForTest()— test helper to reload from env between cases.- Const
CORSAllowedOriginsEnv(MOOV_CORS_ALLOW_ORIGINS).
Deploy / upgrade notes
| Before (≤ v0.62.x) | After (v0.63.0) |
|---|---|
Any https://… Origin got ACAO + credentials |
Only allowlisted Origins (plus loopback HTTP) |
| Env not required for browser CORS | Set MOOV_CORS_ALLOW_ORIGINS wherever credentialed browser calls are expected |
| Server-to-server / non-browser clients | Unaffected (CORS is browser-enforced) |
Example:
MOOV_CORS_ALLOW_ORIGINS=https://moov.io,https://dashboard.moov.ioDependencies
- fix(deps): update module
github.com/rickar/cal/v2to v2.1.29 (#510)
Full Changelog: v0.62.1...v0.63.0