diff --git a/services/identity/src/constants.rs b/services/identity/src/constants.rs --- a/services/identity/src/constants.rs +++ b/services/identity/src/constants.rs @@ -11,7 +11,6 @@ pub const USERS_TABLE_REGISTRATION_ATTRIBUTE: &str = "pakeRegistrationData"; pub const USERS_TABLE_USERNAME_ATTRIBUTE: &str = "username"; pub const USERS_TABLE_USER_PUBLIC_KEY_ATTRIBUTE: &str = "userPublicKey"; -pub const USERS_TABLE_DEVICE_ATTRIBUTE: &str = "device"; pub const USERS_TABLE_DEVICES_ATTRIBUTE: &str = "devices"; pub const USERS_TABLE_DEVICES_MAP_ATTRIBUTE_NAME: &str = "deviceID"; pub const USERS_TABLE_WALLET_ADDRESS_ATTRIBUTE: &str = "walletAddress"; diff --git a/services/identity/src/database.rs b/services/identity/src/database.rs --- a/services/identity/src/database.rs +++ b/services/identity/src/database.rs @@ -20,10 +20,10 @@ ACCESS_TOKEN_TABLE_VALID_ATTRIBUTE, NONCE_TABLE, NONCE_TABLE_CREATED_ATTRIBUTE, NONCE_TABLE_PARTITION_KEY, USERS_TABLE, USERS_TABLE_DEVICES_ATTRIBUTE, USERS_TABLE_DEVICES_MAP_ATTRIBUTE_NAME, - USERS_TABLE_DEVICE_ATTRIBUTE, USERS_TABLE_PARTITION_KEY, - USERS_TABLE_REGISTRATION_ATTRIBUTE, USERS_TABLE_USERNAME_ATTRIBUTE, - USERS_TABLE_USERNAME_INDEX, USERS_TABLE_USER_PUBLIC_KEY_ATTRIBUTE, - USERS_TABLE_WALLET_ADDRESS_ATTRIBUTE, USERS_TABLE_WALLET_ADDRESS_INDEX, + USERS_TABLE_PARTITION_KEY, USERS_TABLE_REGISTRATION_ATTRIBUTE, + USERS_TABLE_USERNAME_ATTRIBUTE, USERS_TABLE_USERNAME_INDEX, + USERS_TABLE_USER_PUBLIC_KEY_ATTRIBUTE, USERS_TABLE_WALLET_ADDRESS_ATTRIBUTE, + USERS_TABLE_WALLET_ADDRESS_INDEX, }; use crate::nonce::NonceData; use crate::token::{AccessTokenData, AuthType}; @@ -378,53 +378,6 @@ } } - pub async fn get_user_public_key( - &self, - user_id: String, - device_id: String, - ) -> Result, Error> { - match self.get_item_from_users_table(&user_id).await { - Ok(GetItemOutput { - item: Some(mut item), - .. - }) => { - // `devices` is a HashMap that maps device IDs to a HashMap of - // device-specific attributes - let mut devices = parse_map_attribute( - USERS_TABLE_DEVICES_ATTRIBUTE, - item.remove(USERS_TABLE_DEVICES_ATTRIBUTE), - )?; - if devices.get(&device_id).is_none() { - return Ok(None); - } - let mut device = parse_map_attribute( - USERS_TABLE_DEVICE_ATTRIBUTE, - devices.remove(&device_id), - )?; - parse_string_attribute( - USERS_TABLE_USER_PUBLIC_KEY_ATTRIBUTE, - device.remove(USERS_TABLE_USER_PUBLIC_KEY_ATTRIBUTE), - ) - .map(Some) - .map_err(Error::Attribute) - } - Ok(_) => { - info!( - "No item found for user {} and device {} in users table", - user_id, device_id - ); - Ok(None) - } - Err(e) => { - error!( - "DynamoDB client failed to get user public key for user {}: {}", - user_id, e - ); - Err(e) - } - } - } - pub async fn get_item_from_users_table( &self, user_id: &str, @@ -685,25 +638,6 @@ } } -fn parse_map_attribute( - attribute_name: &'static str, - attribute_value: Option, -) -> Result, DBItemError> { - match attribute_value { - Some(AttributeValue::M(value)) => Ok(value), - Some(_) => Err(DBItemError::new( - attribute_name, - attribute_value, - DBItemAttributeError::IncorrectType, - )), - None => Err(DBItemError::new( - attribute_name, - attribute_value, - DBItemAttributeError::Missing, - )), - } -} - #[cfg(test)] mod tests { use super::*; diff --git a/services/identity/src/service.rs b/services/identity/src/service.rs --- a/services/identity/src/service.rs +++ b/services/identity/src/service.rs @@ -45,8 +45,8 @@ registration_response::Data::PakeRegistrationResponse, CompareUsersRequest, CompareUsersResponse, DeleteUserRequest, DeleteUserResponse, GenerateNonceRequest, GenerateNonceResponse, GetUserIdRequest, - GetUserIdResponse, GetUserPublicKeyRequest, GetUserPublicKeyResponse, - LoginRequest, LoginResponse, PakeLoginRequest as PakeLoginRequestStruct, + GetUserIdResponse, LoginRequest, LoginResponse, + PakeLoginRequest as PakeLoginRequestStruct, PakeLoginResponse as PakeLoginResponseStruct, RegistrationRequest, RegistrationResponse, VerifyUserTokenRequest, VerifyUserTokenResponse, WalletLoginRequest as WalletLoginRequestStruct, @@ -217,25 +217,6 @@ Ok(response) } - #[instrument(skip(self))] - async fn get_user_public_key( - &self, - request: Request, - ) -> Result, Status> { - let message = request.into_inner(); - let public_key = match self - .client - .get_user_public_key(message.user_id, message.device_id) - .await - { - Ok(Some(public_key)) => public_key, - Ok(None) => return Err(Status::not_found("no public key found")), - Err(e) => return Err(handle_db_error(e)), - }; - let response = Response::new(GetUserPublicKeyResponse { public_key }); - Ok(response) - } - #[instrument(skip(self))] async fn delete_user( &self, diff --git a/shared/protos/identity.proto b/shared/protos/identity.proto --- a/shared/protos/identity.proto +++ b/shared/protos/identity.proto @@ -14,10 +14,6 @@ // Called by users and keyservers to get userID corresponding to a wallet // address or username rpc GetUserID(GetUserIDRequest) returns (GetUserIDResponse) {} - // Called by keyservers to get the public key corresponding to a given user ID - // and device ID - rpc GetUserPublicKey(GetUserPublicKeyRequest) returns - (GetUserPublicKeyResponse) {} rpc DeleteUser(DeleteUserRequest) returns (DeleteUserResponse) {} // Called by Ashoat's keyserver with a list of user IDs in MySQL and returns: @@ -151,17 +147,6 @@ string userID = 1; } -// GetUserPublicKey - -message GetUserPublicKeyRequest { - string userID = 1; - string deviceID = 2; -} - -message GetUserPublicKeyResponse { - string publicKey = 1; -} - // DeleteUser message DeleteUserRequest {