Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3351562
D8825.id29932.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D8825.id29932.diff
View Options
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
@@ -480,6 +480,7 @@
..
}) => {
let created = parse_created_attribute(
+ ACCESS_TOKEN_TABLE_CREATED_ATTRIBUTE,
item.remove(ACCESS_TOKEN_TABLE_CREATED_ATTRIBUTE),
)?;
let auth_type = parse_auth_type_attribute(
@@ -823,6 +824,53 @@
.map_err(|e| Error::AwsSdk(e.into()))
}
+ pub async fn get_nonce_from_nonces_table(
+ &self,
+ nonce_value: String,
+ ) -> Result<Option<NonceData>, Error> {
+ let get_response = self
+ .client
+ .get_item()
+ .table_name(NONCE_TABLE)
+ .key(NONCE_TABLE_PARTITION_KEY, AttributeValue::S(nonce_value))
+ .send()
+ .await
+ .map_err(|e| Error::AwsSdk(e.into()))?;
+
+ let mut item = match get_response.item {
+ Some(item) => item,
+ None => return Ok(None),
+ };
+
+ let nonce = parse_string_attribute(
+ NONCE_TABLE_PARTITION_KEY,
+ item.remove(&NONCE_TABLE_PARTITION_KEY.to_string()),
+ )?;
+
+ let created = parse_created_attribute(
+ NONCE_TABLE_CREATED_ATTRIBUTE,
+ item.remove(&NONCE_TABLE_CREATED_ATTRIBUTE.to_string()),
+ )?;
+
+ Ok(Some(NonceData { nonce, created }))
+ }
+
+ pub async fn remove_nonce_from_nonces_table(
+ &self,
+ nonce: String,
+ ) -> Result<(), Error> {
+ self
+ .client
+ .delete_item()
+ .table_name(NONCE_TABLE)
+ .key(NONCE_TABLE_PARTITION_KEY, AttributeValue::S(nonce))
+ .send()
+ .await
+ .map_err(|e| Error::AwsSdk(e.into()))?;
+
+ Ok(())
+ }
+
pub async fn add_usernames_to_reserved_usernames_table(
&self,
usernames: Vec<String>,
@@ -932,19 +980,20 @@
}
fn parse_created_attribute(
+ attribute_name: &str,
attribute: Option<AttributeValue>,
) -> Result<DateTime<Utc>, DBItemError> {
if let Some(AttributeValue::S(created)) = &attribute {
created.parse().map_err(|e| {
DBItemError::new(
- ACCESS_TOKEN_TABLE_CREATED_ATTRIBUTE.to_string(),
+ attribute_name.to_string(),
attribute,
DBItemAttributeError::InvalidTimestamp(e),
)
})
} else {
Err(DBItemError::new(
- ACCESS_TOKEN_TABLE_CREATED_ATTRIBUTE.to_string(),
+ attribute_name.to_string(),
attribute,
DBItemAttributeError::Missing,
))
diff --git a/services/identity/src/error.rs b/services/identity/src/error.rs
--- a/services/identity/src/error.rs
+++ b/services/identity/src/error.rs
@@ -49,5 +49,7 @@
#[display(...)]
InvalidTimestamp(chrono::ParseError),
#[display(...)]
+ ExpiredTimestamp,
+ #[display(...)]
InvalidValue,
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Nov 24, 2:31 AM (17 h, 32 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2573551
Default Alt Text
D8825.id29932.diff (2 KB)
Attached To
Mode
D8825: [identity] helper functions to interact with nonces table
Attached
Detach File
Event Timeline
Log In to Comment