diff --git a/services/identity/Cargo.lock b/services/identity/Cargo.lock --- a/services/identity/Cargo.lock +++ b/services/identity/Cargo.lock @@ -686,6 +686,7 @@ version = "0.1.0" dependencies = [ "argon2", + "bytes", "chrono", "clap", "curve25519-dalek", diff --git a/services/identity/Cargo.toml b/services/identity/Cargo.toml --- a/services/identity/Cargo.toml +++ b/services/identity/Cargo.toml @@ -21,6 +21,7 @@ tracing-subscriber = "0.3" chrono = "0.4.19" rand = "0.8" +bytes = "1.1" [build-dependencies] tonic-build = "0.6" 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 @@ -1,11 +1,12 @@ use std::collections::HashMap; +use bytes::Bytes; use chrono::{DateTime, ParseError, Utc}; use opaque_ke::{errors::ProtocolError, ServerRegistration}; use rusoto_core::{Region, RusotoError}; use rusoto_dynamodb::{ AttributeValue, DynamoDb, DynamoDbClient, GetItemError, GetItemInput, - GetItemOutput, + GetItemOutput, PutItemError, PutItemInput, PutItemOutput, }; use tracing::{error, info}; @@ -79,6 +80,34 @@ } } + pub async fn put_pake_registration( + &self, + user_id: String, + registration: ServerRegistration, + ) -> Result> { + let input = PutItemInput { + table_name: "identity-pake-registration".to_string(), + item: HashMap::from([ + ( + "userID".to_string(), + AttributeValue { + s: Some(user_id), + ..Default::default() + }, + ), + ( + "pakeRegistrationData".to_string(), + AttributeValue { + b: Some(Bytes::from(registration.serialize())), + ..Default::default() + }, + ), + ]), + ..PutItemInput::default() + }; + self.client.put_item(input).await + } + pub async fn get_token( &self, user_id: String,