Skip to content

Use secure cookies only when HTTPS is expected#6430

Merged
tomhughes merged 2 commits intoopenstreetmap:masterfrom
pablobm:secure-cookies-on-production
Oct 6, 2025
Merged

Use secure cookies only when HTTPS is expected#6430
tomhughes merged 2 commits intoopenstreetmap:masterfrom
pablobm:secure-cookies-on-production

Conversation

@pablobm
Copy link
Contributor

@pablobm pablobm commented Oct 6, 2025

Two changes:

  • DRY up the code handling JS cookies.
    • It's very repetitive as every single instance repeats the arguments { secure: true, path: "/", samesite: "lax" }.
    • We can avoid this using Cookies.withAttributes, creating a preset that I have placed at OSM.cookies.
    • Argument expires left in place as it does change in each instance.
  • Change secure: true to only apply when HTTPS is expected. This is, when Settings.server_protocol == "https".

This change is extracted from #6424. Over there it was done so that system tests work with remote Selenium.

This is particularly important if running system tests with
a remote Selenium instance. HTTPS and localhost are considered
"secure" for this purpose, while a remote Selenium will connect
to the app with HTTP instead.
@tomhughes
Copy link
Member

Looks good to me, thanks.

@tomhughes tomhughes merged commit c943c3e into openstreetmap:master Oct 6, 2025
12 checks passed
@pablobm pablobm deleted the secure-cookies-on-production branch October 22, 2025 09:05
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.

2 participants