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 @@ -1,32 +1,34 @@ // Secrets -pub const SECRETS_DIRECTORY: &str = "secrets"; -pub const SECRETS_FILE_NAME: &str = "secret_key"; -pub const SECRETS_FILE_EXTENSION: &str = "txt"; +pub const SECRETS_DIRECTORY: &'static str = "secrets"; +pub const SECRETS_FILE_NAME: &'static str = "secret_key"; +pub const SECRETS_FILE_EXTENSION: &'static str = "txt"; // DynamoDB -pub const USERS_TABLE: &str = "identity-users"; -pub const USERS_TABLE_PARTITION_KEY: &str = "userID"; -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_WALLET_ADDRESS_ATTRIBUTE: &str = "walletAddress"; -pub const USERS_TABLE_USERNAME_INDEX: &str = "username-index"; -pub const USERS_TABLE_WALLET_ADDRESS_INDEX: &str = "walletAddress-index"; - -pub const ACCESS_TOKEN_TABLE: &str = "identity-tokens"; -pub const ACCESS_TOKEN_TABLE_PARTITION_KEY: &str = "userID"; -pub const ACCESS_TOKEN_SORT_KEY: &str = "deviceID"; -pub const ACCESS_TOKEN_TABLE_CREATED_ATTRIBUTE: &str = "created"; -pub const ACCESS_TOKEN_TABLE_AUTH_TYPE_ATTRIBUTE: &str = "authType"; -pub const ACCESS_TOKEN_TABLE_VALID_ATTRIBUTE: &str = "valid"; -pub const ACCESS_TOKEN_TABLE_TOKEN_ATTRIBUTE: &str = "token"; +pub const USERS_TABLE: &'static str = "identity-users"; +pub const USERS_TABLE_PARTITION_KEY: &'static str = "userID"; +pub const USERS_TABLE_REGISTRATION_ATTRIBUTE: &'static str = + "pakeRegistrationData"; +pub const USERS_TABLE_USERNAME_ATTRIBUTE: &'static str = "username"; +pub const USERS_TABLE_USER_PUBLIC_KEY_ATTRIBUTE: &'static str = "userPublicKey"; +pub const USERS_TABLE_WALLET_ADDRESS_ATTRIBUTE: &'static str = "walletAddress"; +pub const USERS_TABLE_USERNAME_INDEX: &'static str = "username-index"; +pub const USERS_TABLE_WALLET_ADDRESS_INDEX: &'static str = + "walletAddress-index"; + +pub const ACCESS_TOKEN_TABLE: &'static str = "identity-tokens"; +pub const ACCESS_TOKEN_TABLE_PARTITION_KEY: &'static str = "userID"; +pub const ACCESS_TOKEN_SORT_KEY: &'static str = "deviceID"; +pub const ACCESS_TOKEN_TABLE_CREATED_ATTRIBUTE: &'static str = "created"; +pub const ACCESS_TOKEN_TABLE_AUTH_TYPE_ATTRIBUTE: &'static str = "authType"; +pub const ACCESS_TOKEN_TABLE_VALID_ATTRIBUTE: &'static str = "valid"; +pub const ACCESS_TOKEN_TABLE_TOKEN_ATTRIBUTE: &'static str = "token"; // Tokio pub const MPSC_CHANNEL_BUFFER_CAPACITY: usize = 1; -pub const IDENTITY_SERVICE_SOCKET_ADDR: &str = "[::]:50051"; +pub const IDENTITY_SERVICE_SOCKET_ADDR: &'static str = "[::]:50051"; // Token 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 @@ -91,20 +91,22 @@ if let Some(reg) = registration { update_expression_parts .push(format!("{} = :r", USERS_TABLE_REGISTRATION_ATTRIBUTE)); - expression_attribute_values - .insert(":r".into(), AttributeValue::B(Blob::new(reg.serialize()))); + expression_attribute_values.insert( + ":r".to_string(), + AttributeValue::B(Blob::new(reg.serialize())), + ); }; if let Some(username) = username { update_expression_parts .push(format!("{} = :u", USERS_TABLE_USERNAME_ATTRIBUTE)); expression_attribute_values - .insert(":u".into(), AttributeValue::S(username)); + .insert(":u".to_string(), AttributeValue::S(username)); }; if let Some(public_key) = user_public_key { update_expression_parts .push(format!("{} = :k", USERS_TABLE_USER_PUBLIC_KEY_ATTRIBUTE)); expression_attribute_values - .insert(":k".into(), AttributeValue::S(public_key)); + .insert(":k".to_string(), AttributeValue::S(public_key)); }; self @@ -188,30 +190,30 @@ ) -> Result { let item = HashMap::from([ ( - ACCESS_TOKEN_TABLE_PARTITION_KEY.into(), + ACCESS_TOKEN_TABLE_PARTITION_KEY.to_string(), AttributeValue::S(access_token_data.user_id), ), ( - ACCESS_TOKEN_SORT_KEY.into(), + ACCESS_TOKEN_SORT_KEY.to_string(), AttributeValue::S(access_token_data.device_id), ), ( - ACCESS_TOKEN_TABLE_TOKEN_ATTRIBUTE.into(), + ACCESS_TOKEN_TABLE_TOKEN_ATTRIBUTE.to_string(), AttributeValue::S(access_token_data.access_token), ), ( - ACCESS_TOKEN_TABLE_CREATED_ATTRIBUTE.into(), + ACCESS_TOKEN_TABLE_CREATED_ATTRIBUTE.to_string(), AttributeValue::S(access_token_data.created.to_rfc3339()), ), ( - ACCESS_TOKEN_TABLE_AUTH_TYPE_ATTRIBUTE.into(), + ACCESS_TOKEN_TABLE_AUTH_TYPE_ATTRIBUTE.to_string(), AttributeValue::S(match access_token_data.auth_type { AuthType::Password => "password".to_string(), AuthType::Wallet => "wallet".to_string(), }), ), ( - ACCESS_TOKEN_TABLE_VALID_ATTRIBUTE.into(), + ACCESS_TOKEN_TABLE_VALID_ATTRIBUTE.to_string(), AttributeValue::Bool(access_token_data.valid), ), ]);