mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-11-28 03:17:32 +00:00
fix: Serialize OAuth session mutations per device
Concurrent token refreshes or API requests clearing the previous refresh token could overwrite userdeviceid_oauthsessioninfo with stale session state or leave orphaned entries in refreshtoken_refreshtokeninfo. Guard session mutations with a per-device MutexMap and re-read session info under the lock when clearing the previous refresh token.
This commit is contained in:
2 files changed
+44
-18
No files matched your search
@@ -324,12 +324,14 @@ async fn check_access_token(
|
||||
.get_session_info_for_device(&sender_user, &sender_device)
|
||||
.await;
|
||||
|
||||
if let Some(session_info) = &session_info {
|
||||
services.oauth.clear_previous_refresh_token(
|
||||
&sender_user,
|
||||
&sender_device,
|
||||
session_info,
|
||||
);
|
||||
if session_info
|
||||
.as_ref()
|
||||
.is_some_and(|info| info.has_previous_refresh_token())
|
||||
{
|
||||
services
|
||||
.oauth
|
||||
.clear_previous_refresh_token(&sender_user, &sender_device)
|
||||
.await;
|
||||
}
|
||||
|
||||
// Locked users can only use /logout and /logout/all
|
||||
|
||||
Reference in new issue
Block a user