This commit is contained in:
cy 2025-03-14 06:28:54 +00:00 committed by GitHub
commit 0f13cb97e4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 3 deletions

View file

@ -4,7 +4,7 @@ use std::{
};
use conduwuit::{
Error, Result, err, error, implement, utils,
Err, Error, Result, err, error, implement, utils,
utils::{hash, string::EMPTY},
};
use database::{Deserialized, Json, Map};
@ -150,12 +150,18 @@ pub async fn try_auth(
));
};
let user_id = UserId::parse_with_server_name(
let user_id_from_username = UserId::parse_with_server_name(
username.clone(),
self.services.globals.server_name(),
)
.map_err(|_| Error::BadRequest(ErrorKind::InvalidParam, "User ID is invalid."))?;
// Check if the access token being used matches the credentials used for UIAA
if user_id.localpart() != user_id_from_username.localpart() {
return Err!(Request(Forbidden("User ID and access token mismatch.")));
}
let user_id = user_id_from_username;
// Check if password is correct
if let Ok(hash) = self.services.users.password_hash(&user_id).await {
let hash_matches = hash::verify_password(password, &hash).is_ok();

View file

@ -127,7 +127,7 @@
{"Action":"fail","Test":"TestDeviceListsUpdateOverFederationOnRoomJoin"}
{"Action":"fail","Test":"TestDeviceManagement"}
{"Action":"fail","Test":"TestDeviceManagement/DELETE_/device/{deviceId}"}
{"Action":"fail","Test":"TestDeviceManagement/DELETE_/device/{deviceId}_requires_UI_auth_user_to_match_device_owner"}
{"Action":"pass","Test":"TestDeviceManagement/DELETE_/device/{deviceId}_requires_UI_auth_user_to_match_device_owner"}
{"Action":"pass","Test":"TestDeviceManagement/GET_/device/{deviceId}"}
{"Action":"pass","Test":"TestDeviceManagement/GET_/device/{deviceId}_gives_a_404_for_unknown_devices"}
{"Action":"pass","Test":"TestDeviceManagement/GET_/devices"}