Auto-acquire and renew the Strava session from login credentials #6
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Context
High-resolution mode currently requires a manually copied session cookie: sign in to strava.com in a browser, dig out
_strava4_sessionfrom devtools, and set it asSTRAVA_SESSION_COOKIE. TheCookieManagerthen exchanges that static cookie for short-lived CloudFront cookies and refreshes those automatically every 12h — but the_strava4_sessionvalue itself is never renewed.When the Strava session expires, high-res tiles silently degrade to anonymous mode (zoom 11) until a human repeats the copy-paste ritual and restarts the container. On deployments managed by CI (e.g. tofu-maison), it also means updating a secret and re-applying.
Proposal
Let the proxy acquire and renew the session itself from credentials:
STRAVA_EMAIL+STRAVA_PASSWORD.GET https://www.strava.com/login→ extract the CSRF token from the form →POSTcredentials → capture_strava4_sessionfrom theSet-Cookieresponse → hand it to the existingCookieManager.RefreshFailedpersists / no CloudFront cookies returned), re-run the login flow with a backoff, reusing the existing cooldown pattern.STRAVA_SESSION_COOKIEkeeps working as-is: explicit cookie takes precedence when both are set; credentials mode only kicks in when no cookie is provided.Risks / open questions
Acceptance
STRAVA_EMAIL/STRAVA_PASSWORDset (and no cookie),/api/configreportsauthenticated: true,maxZoom: 15.Live diagnosis from production (2026-10-02) — relevant to the login/password design:
Strava now requires a second cookie for high-res tiles.
content-a.strava.com/identified/*rejects CloudFront-cookies-only requests with 401. Probes with a real logged-in session:_strava_idcfDetails:
_strava_idcfis a short-lived (~24 h) JWT bound to the athlete ({"exp":…,"iat":…,"athleteId":…}).CookieManager::fetch_cookiesalready performs emits_strava_idcfas a Set-Cookie alongside the CloudFront trio — the proxy just never parsed/forwarded it (fix in progress: capture + forward it)._strava4_sessionis now a 32-char opaque token (server-side sessions), not the long Rails blob older tooling describes.Implication for this issue: the credential login flow must maintain a small cookie jar — after POST /session and on every exchange, harvest
_strava4_sessionand_strava_idcf, and send both (plus the CloudFront trio) on tile requests. A single session string won't be enough.