Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set language cookie domain to allow for cross-domain cookies #3647

Merged

Conversation

chrisgarrity
Copy link
Contributor

@chrisgarrity chrisgarrity commented Jan 22, 2020

Resolves:

Part of fixing #3325

Changes:

Add leading . to the current hostname for the language cookie domain.

The scratchlanguage cookie was being set as scratch.mit.edu rather than .scratch.mit.edu, note the leading . Other backend servers processing the project creation did not have access to the cookie.

Test Coverage:

Manual testing prerequisites:

  • access to the database where project metadata is stored
  • open dev tools and delete the scratchlanguage cookie
  • default language setting in the browser is used if cookie is not set
    • open browser settings and add another language, place it first in the language list
    • click create
    • editor loads in the new default language, and the project in the database has the same language in metadata

Delete the cookie in between these tests:

  • scratchlanguage cookie is used if set on www
    • On a www page (e.g., home, explore...), choose a language in the language menu
    • create a project
    • editor loads in the new language, and project in the database also has the same language
    • in devtools...Application...Cookies, the domain for the scratchlanguage cookie starts with .
  • scratchlanguage cookie is used if set on scratchr2
    • On a scratchr2 page (e.g., profile, studios), choose a language in the language menu
    • create a project
    • editor loads in the new language, and project in the database also has the same language
    • in devtools...Application...Cookies, the domain for the scratchlanguage cookie starts with .
  • scratchlanguage cookie is used if set in the editor
    • In the editor, change language
    • use File...New to create a new project
    • editor loads in the new language, and project in the database also has the same language
  • in devtools...Application...Cookies, the domain for the scratchlanguage cookie starts with .

Add leading `.` to the current hostname for the language cookie domain.
Need to special case localhost so that changing language works when running locally.
@chrisgarrity
Copy link
Contributor Author

This seems like a candidate for not testing on all browsers since it's mostly back-end. Then again, do we trust cookies to work the same on every browser? /cc @BryceLTaylor

@chrisgarrity chrisgarrity removed their assignment Jan 28, 2020
@rschamp
Copy link
Contributor

rschamp commented Jan 28, 2020

I think we probably should test on several browsers once this is on scratch.ly, but we probably don't need to bring it to the bug hunt for everyone to look at.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants