fix: Return the correct scope list when refreshing an OAuth access token

This commit is contained in:
Ginger committed 2026-11-23 09:26:50 -05:00
1 parent 9a3ed04eb6
commit 4a4c25843b
1 file changed
+11 -3
+11 -3
View File
@@ -1,5 +1,6 @@
use std::{
collections::{BTreeSet, HashMap},
fmt::Write,
sync::Arc,
time::{Duration, SystemTime},
};
@@ -73,6 +74,15 @@ impl SessionInfo {
pub fn scopes(&self) -> BTreeSet<OAuthClientScope> {
self.scopes.union(&self.temporary_scopes).cloned().collect()
}
#[must_use]
pub fn scope_string(&self, device_id: &DeviceId) -> String {
let mut scopes = self.scopes().iter().join(" ");
let _ = write!(scopes, " urn:matrix:client:device:{device_id}");
scopes
}
}
#[derive(Debug, Deserialize, Serialize)]
@@ -767,9 +777,7 @@ impl Service {
panic!("refresh token is not current or previous for its session");
}
// TODO: this doesn't include the device ID "scope", do any clients rely
// on that?
let scope = session_info.scopes.iter().join(" ");
let scope = session_info.scope_string(&refresh_token_info.device_id);
let new_access_token = DeviceToken::new_random().with_max_age(Self::ACCESS_TOKEN_MAX_AGE);