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

iOS 12 devices cannot login cofacts.tw #259

Open
MrOrz opened this issue Aug 2, 2021 · 1 comment
Open

iOS 12 devices cannot login cofacts.tw #259

MrOrz opened this issue Aug 2, 2021 · 1 comment

Comments

@MrOrz
Copy link
Member

MrOrz commented Aug 2, 2021

No matter which domain they use, iOS 12 users are not able to login Cofacts, regardless of they logged in Cofacts in other devices before.

截圖 2021-08-03 上午12 34 35

Root cause

iOS <=12 has a bug in its webkit core, which will interpret SameSite=None as SameSite=Strict.
https://medium.com/reactfunctioncomponentnote/samesite-%E4%B9%8B%E4%BA%82-f7e1645642bf

When SameSite=Strict, browser will not send cookie even we are redirecting the whole page as long as the source (in this case, the authenticating service like FB, Google, etc) and destination URL (api.cofacts.tw/callback/*) are not in the same "site" (That is, *.cofacts.tw).

Therefore, iOS 12 will not send session cookie to /callback/* endpoint, and the endpoint cannot proceed without such session keys.

Proposed changes

Consider the following facts:

  • All cookies without SameSite flag will be Lax by default, which does not send cookie for cross-site "sub-requests" (images, frames) but allows cross-site cookies for navigations. Therefore, the default SameSite=Lax does not interfere OAuth login redirect.
  • In iOS cannot login cofacts.tw #250 we have moved APIs and sites to the same site (cofacts.tw) by default. Therefore, Site <> API communication are all same-site requests
  • iOS <=12 should work on cofacts.tw without any SameSite flags (needs test)

Therefore we should be able to drop SameSite flag at once.

  • Remove samesite logic
  • Remove related COOKIE_SAMESITE_NONE and HTTPS
  • For localhost development (localhost and staging API are definately cross-site), use /api proxy in localhost environment (See Method 2 in Cannot login to local dev server #186 (comment) )
@MrOrz MrOrz changed the title iOS 12 devices cannot login Cofacts website iOS 12 devices cannot login cofacts.tw Aug 2, 2021
@MrOrz
Copy link
Member Author

MrOrz commented Aug 18, 2021

Conclusion: According to 0804 discussion

We will detect iOS <= 12 with user-agent header and do not set same-site flag if iOS <= 12 is detected.

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

No branches or pull requests

1 participant