On browsers like safari and brave, cookies set on the client side are caped to 7 days expiry (https://www.cookiestatus.com/)
This means that tokens like frontToken, or idrefreshtoken, or anticsrftoken that are set in cookies will be deleted after 7 days.
We can use localstorage instead, but this means that working across sub domains will not be possible:
We can create an API on the backend that says if a session exists or not. If it does, then it will set these tokens in localstorage. But this has an issue that if these tokens are deleted from one sub domain's localstorage, they will persist in the next sub domain's localstorage (even if the session doesn't exist).
In case the user is using an anti-csrf token, then the new suddomain cannot get that token at all.
We can continue to use cookies and also have an API in case no cookies exist (after 7 days)
This will work well, as long as the user is not using anti-csrf tokens, since after 7 days, that anti-csrf token will be missing, and can't be recovered -> which will yield a logout.
Finally, we decided to go with an iframe method that will allow us to share localstorage across sub domains.
frontToken
, oridrefreshtoken
, oranticsrftoken
that are set in cookies will be deleted after 7 days.Finally, we decided to go with an iframe method that will allow us to share localstorage across sub domains.
TODO:
getUserId
and todoesSessionExist
(they both are now async)requireAuth
boolean in Auth wrapper and session wrapper