Commit Graph

15 Commits

Author SHA1 Message Date
833a5d1191 fix: sso refresh token race condition (#405)
With NextAuth, there is a race condition of the current implementation
of refreshToken using multiple tab. Because getSession() is broadcasted
(or triggered by another component, window focus or such), we may ask
for the jwt() to be refreshed at the same time.

The problem is the first time will go correctly, while all others calls
will be rejected as they are using a revoked token.

This redis lock is per-user, and will use redis lock as a source of
truth.
2024-09-05 00:47:02 +02:00
03561453c5 feat: Monadical SSO as replacement of Fief (#393)
* sso: first pass for integrating SSO

still have issue on refreshing
maybe customize the login page, or completely avoid it
make 100% to understand how session server/client are working
need to test with different configuration option (features flags and
requireLogin)

* sso: correctly handle refresh token, with pro-active refresh

Going on interceptors make extra calls to reflector when 401.
We need then to circle back with NextJS backend to update the jwt,
session, then retry the failed request.

I prefered to go pro-active, and ensure the session AND jwt are always
up to date.

A minute before the expiration, we'll try to refresh it. useEffect() of
NextJS cannot be asynchronous, so we cannot wait for the token to be
refreshed.

Every 20s, a minute before the expiration (so 3x in total max) we'll try
to renew. When the accessToken is renewed, the session is updated, and
dispatching up to the client, which updates the useApi().

Therefore, no component will left without a incorrect token.

* fixes: issue with missing key on react-select-search because the default value is undefined

* sso: fixes login/logout button, and avoid seeing the login with authentik page when clicking

* sso: ensure /transcripts/new is not behind protected page, and feature flags page are honored

* sso: fixes user sub->id

* fixes: remove old layout not used

* fixes: set default NEXT_PUBLIC_SITE_URL as localhost

* fixes: removing fief again due to merge with main

* sso: ensure session is always ready before doing any action

* sso: add migration from fief to jwt in server, only from transcripts list

* fixes: user tests

* fixes: compilation issues
2024-09-03 19:27:15 +02:00
b84efd1c61 Refactor getConfig calls 2024-09-02 12:16:06 +02:00
e01a4dbd9a Get config domain from env var 2024-09-02 12:03:45 +02:00
b019e81b9b Remove domain segment 2024-09-01 01:20:00 +02:00
14212c802d Shorten room urls 2024-08-30 12:38:14 +02:00
ef29913036 Redirect rooms to login 2024-08-22 22:53:35 +02:00
55697e670d Permanent room urls 2024-08-19 17:56:32 +02:00
Sara
61d1e6b06b fix local and preview config 2023-11-02 12:24:52 +01:00
Sara
3a12ebd7e1 tweak prefetch on links 2023-11-02 12:24:52 +01:00
Sara
18c0d7a13b fix authentication issue 2023-11-02 12:24:52 +01:00
Sara
7ca152992c fix typings and edge config key issue 2023-11-02 12:24:52 +01:00
Sara
4a69bffc9c Implement multi tenancy 2023-11-02 12:24:52 +01:00
ef2f579fc1 www: add feature to enforce login on transcripts record/past/browse 2023-11-02 12:24:52 +01:00
Koper
1b1e67901c FIEF NextJS 2023-08-17 22:57:59 +07:00