Closed Stimim closed 4 years ago
https://www.chromium.org/updates/same-site
rumors-api
has not add SameSite: none; secure
to its cookieA cookie associated with a cross-site resource at http://cofacts-api.g0v.tw/ was set without the
SameSite
attribute. A future release of Chrome will only deliver cookies with cross-site requests if they are set withSameSite=None
andSecure
. You can review cookies in developer tools under Application>Storage>Cookies and see more details at https://www.chromestatus.com/feature/5088147346030592 and https://www.chromestatus.com/feature/5633521622188032.
The message is different from the one @Stimim received. The difference is marked italic, stating that the browser has not blocked the cookie yet; while Stimim's browser is chosen by Google and blocked cookies according to SameSite rules.
For users with a browser that enforces same-site, they will have issue when
However, cofacts.g0v.tw
and cofacts-api.g0v.tw
are considered same-site, cofacts.hacktabl.org
and cofacts-api.hacktabl.org
are also considered same-site, thus these are already "same-site" and can still work under the default SameSite: Lax
behavior.
Definition of "same-site": https://web.dev/samesite-cookies-explained/#explicitly-state-cookie-usage-with-the-samesite-attribute
There are 3 ways to mitigate the same-site change:
Since rumors-api acts as an authentication service, its cookie should be sent in third party context. We should set SameSite: none; secure
on the login cookies set by rumors-api
.
After enforcing samesite on rumors-api, we may encounter issue developing using http://localhost:3000
. Need to investigate workarounds, or provide documentation for devs to setup https on localhost.
Another way to mitigate is to keep API endpoints always same-site, so that same-site cookie rules never need to apply.
*.cofacts.org
, use api.cofacts.org
as API endpoint
/api/
to API servers instead
proxy_pass
No cookie, no headache! In this way, there is nothing that will "automatically" sent to server, thus no CSRF risks -- as long as the token is not intercepted :P
However, this requires clients like rumors-site to remember the token in other means (such as localStorage
) if we don't want users to login after reloading the website / opening a new tab. Other things are:
code
in URL after successful authentication, and the client uses the code
to exchange for token
and store it in client side.Working on a branch to mitigate this, but blocked by secure
detection issue:
As secure cookie & SameSite: none being set, this issue should be resolved on staging. Visitors of localhost:3000
should be able to login staging server with no problem
If Google Chrome still complains about cross-site cookie, try clearing the cookie stored for localhost:3000 and try again. Safari login should also work as expected.
cc/ @Stimim
How to Reproduce
npm run dev
to start a dev server.Login
button in top right corner.Login
button is still shown in top right corner.Additional Info
In both browser, there is no cookie from cofacts domain.
Google Chrome
Found the following message in developer console:
Safari
Found the following message in javascript console: