Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3363101
D11072.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
D11072.diff
View Options
diff --git a/services/identity/src/client_service.rs b/services/identity/src/client_service.rs
--- a/services/identity/src/client_service.rs
+++ b/services/identity/src/client_service.rs
@@ -386,24 +386,7 @@
&message.siwe_signature,
)?;
- match self
- .client
- .get_nonce_from_nonces_table(&parsed_message.nonce)
- .await
- .map_err(handle_db_error)?
- {
- None => return Err(tonic::Status::invalid_argument("invalid nonce")),
- Some(nonce) if nonce.is_expired() => {
- // we don't need to remove the nonce from the table here
- // because the DynamoDB TTL will take care of it
- return Err(tonic::Status::aborted("nonce expired"));
- }
- Some(_) => self
- .client
- .remove_nonce_from_nonces_table(&parsed_message.nonce)
- .await
- .map_err(handle_db_error)?,
- };
+ self.verify_and_remove_nonce(&parsed_message.nonce).await?;
let wallet_address = eip55(&parsed_message.address);
@@ -509,19 +492,7 @@
&message.siwe_signature,
)?;
- match self
- .client
- .get_nonce_from_nonces_table(&parsed_message.nonce)
- .await
- .map_err(handle_db_error)?
- {
- None => return Err(tonic::Status::invalid_argument("invalid nonce")),
- Some(_) => self
- .client
- .remove_nonce_from_nonces_table(&parsed_message.nonce)
- .await
- .map_err(handle_db_error)?,
- };
+ self.verify_and_remove_nonce(&parsed_message.nonce).await?;
let wallet_address = eip55(&parsed_message.address);
@@ -760,6 +731,31 @@
}
Ok(())
}
+
+ async fn verify_and_remove_nonce(
+ &self,
+ nonce: &str,
+ ) -> Result<(), tonic::Status> {
+ match self
+ .client
+ .get_nonce_from_nonces_table(nonce)
+ .await
+ .map_err(handle_db_error)?
+ {
+ None => return Err(tonic::Status::invalid_argument("invalid nonce")),
+ Some(nonce) if nonce.is_expired() => {
+ // we don't need to remove the nonce from the table here
+ // because the DynamoDB TTL will take care of it
+ return Err(tonic::Status::aborted("nonce expired"));
+ }
+ Some(nonce_data) => self
+ .client
+ .remove_nonce_from_nonces_table(&nonce_data.nonce)
+ .await
+ .map_err(handle_db_error)?,
+ };
+ Ok(())
+ }
}
#[tonic::async_trait]
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Nov 26, 12:04 AM (21 h, 12 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2581756
Default Alt Text
D11072.diff (2 KB)
Attached To
Mode
D11072: [identity] Extract function to verify nonce
Attached
Detach File
Event Timeline
Log In to Comment