cofacts / rumors-api

GraphQL API server for clients like rumors-site and rumors-line-bot
https://api.cofacts.tw
MIT License
110 stars 26 forks source link

iOS 12 devices cannot login cofacts.tw #259

Open MrOrz opened 3 years ago

MrOrz commented 3 years ago

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:

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

MrOrz commented 3 years ago

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.