Page MenuHomePhabricator

D6691.diff
No OneTemporary

D6691.diff

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
@@ -25,8 +25,8 @@
USERS_TABLE_USERNAME_INDEX, USERS_TABLE_USER_PUBLIC_KEY_ATTRIBUTE,
USERS_TABLE_WALLET_ADDRESS_ATTRIBUTE, USERS_TABLE_WALLET_ADDRESS_INDEX,
};
-use comm_opaque::Cipher;
use crate::token::{AccessTokenData, AuthType};
+use comm_opaque::Cipher;
#[derive(Clone)]
pub struct DatabaseClient {
@@ -138,6 +138,49 @@
.map_err(|e| Error::AwsSdk(e.into()))
}
+ pub async fn add_user_to_users_table(
+ &self,
+ user_id: String,
+ device_id: String,
+ registration: ServerRegistration<Cipher>,
+ username: String,
+ user_public_key: String,
+ ) -> Result<PutItemOutput, Error> {
+ let item = HashMap::from([
+ (
+ USERS_TABLE_PARTITION_KEY.to_string(),
+ AttributeValue::S(user_id),
+ ),
+ (
+ USERS_TABLE_USERNAME_ATTRIBUTE.to_string(),
+ AttributeValue::S(username),
+ ),
+ (
+ USERS_TABLE_REGISTRATION_ATTRIBUTE.to_string(),
+ AttributeValue::B(Blob::new(registration.serialize())),
+ ),
+ (
+ USERS_TABLE_DEVICES_ATTRIBUTE.to_string(),
+ AttributeValue::M(HashMap::from([(
+ device_id,
+ AttributeValue::M(HashMap::from([(
+ USERS_TABLE_USER_PUBLIC_KEY_ATTRIBUTE.to_string(),
+ AttributeValue::S(user_public_key),
+ )])),
+ )])),
+ ),
+ ]);
+
+ self
+ .client
+ .put_item()
+ .table_name(USERS_TABLE)
+ .set_item(Some(item))
+ .send()
+ .await
+ .map_err(|e| Error::AwsSdk(e.into()))
+ }
+
pub async fn get_access_token_data(
&self,
user_id: String,
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
@@ -1,5 +1,6 @@
use aws_sdk_dynamodb::Error as DynamoDBError;
use chrono::Utc;
+use comm_opaque::Cipher;
use constant_time_eq::constant_time_eq;
use futures_core::Stream;
use opaque_ke::{
@@ -16,7 +17,6 @@
use tokio_stream::{wrappers::ReceiverStream, StreamExt};
use tonic::{Request, Response, Status};
use tracing::{error, info, instrument};
-use comm_opaque::Cipher;
use crate::constants::MPSC_CHANNEL_BUFFER_CAPACITY;
use crate::database::DatabaseClient;

File Metadata

Mime Type
text/plain
Expires
Thu, Dec 19, 7:01 PM (20 h, 35 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2678487
Default Alt Text
D6691.diff (2 KB)

Event Timeline