Page MenuHomePhabricator

D4286.id13718.diff
No OneTemporary

D4286.id13718.diff

diff --git a/native/cpp/CommonCpp/grpc/protos/identity.proto b/native/cpp/CommonCpp/grpc/protos/identity.proto
--- a/native/cpp/CommonCpp/grpc/protos/identity.proto
+++ b/native/cpp/CommonCpp/grpc/protos/identity.proto
@@ -42,7 +42,7 @@
// Answer sent to the user upon reception of the PAKE login attempt,
// containing a sealed envelope with the user's private key (step 2)
bytes pakeCredentialResponse = 1;
- string token = 2;
+ string accessToken = 2;
}
}
@@ -58,12 +58,12 @@
message WalletLoginRequest {
string userID = 1;
string deviceID = 2;
- string walletAddress = 3;
- bytes signedMessage = 4;
+ string siweMessage = 3;
+ bytes siweSignature = 4;
}
message WalletLoginResponse {
- bytes token = 1;
+ string accessToken = 1;
}
// RegisterUser
@@ -110,7 +110,7 @@
message VerifyUserTokenRequest {
string userID = 1;
string deviceID = 2;
- string token = 3;
+ string accessToken = 3;
}
message VerifyUserTokenResponse {
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
@@ -11,7 +11,7 @@
use tracing::{error, info};
use crate::opaque::Cipher;
-use crate::token::{AccessToken, AuthType};
+use crate::token::{AccessTokenData, AuthType};
pub struct DatabaseClient {
client: DynamoDbClient,
@@ -108,11 +108,11 @@
self.client.put_item(input).await
}
- pub async fn get_token(
+ pub async fn get_access_token_data(
&self,
user_id: String,
device_id: String,
- ) -> Result<Option<AccessToken>, Error> {
+ ) -> Result<Option<AccessTokenData>, Error> {
let primary_key = create_composite_primary_key(
("userID".to_string(), user_id.clone()),
("deviceID".to_string(), device_id.clone()),
@@ -132,11 +132,11 @@
let created = parse_created_attribute(item.remove("created"))?;
let auth_type = parse_auth_type_attribute(item.remove("authType"))?;
let valid = parse_valid_attribute(item.remove("valid"))?;
- let token = parse_token_attribute(item.remove("token"))?;
- Ok(Some(AccessToken {
+ let access_token = parse_token_attribute(item.remove("token"))?;
+ Ok(Some(AccessTokenData {
user_id,
device_id,
- token,
+ access_token,
created,
auth_type,
valid,
@@ -159,9 +159,9 @@
}
}
- pub async fn put_token(
+ pub async fn put_access_token_data(
&self,
- token: AccessToken,
+ access_token_data: AccessTokenData,
) -> Result<PutItemOutput, Error> {
let input = PutItemInput {
table_name: "identity-tokens".to_string(),
@@ -169,35 +169,35 @@
(
"userID".to_string(),
AttributeValue {
- s: Some(token.user_id),
+ s: Some(access_token_data.user_id),
..Default::default()
},
),
(
"deviceID".to_string(),
AttributeValue {
- s: Some(token.device_id),
+ s: Some(access_token_data.device_id),
..Default::default()
},
),
(
"token".to_string(),
AttributeValue {
- s: Some(token.token),
+ s: Some(access_token_data.access_token),
..Default::default()
},
),
(
"created".to_string(),
AttributeValue {
- s: Some(token.created.to_rfc3339()),
+ s: Some(access_token_data.created.to_rfc3339()),
..Default::default()
},
),
(
"authType".to_string(),
AttributeValue {
- s: Some(match token.auth_type {
+ s: Some(match access_token_data.auth_type {
AuthType::Password => "password".to_string(),
AuthType::Wallet => "wallet".to_string(),
}),
@@ -207,7 +207,7 @@
(
"valid".to_string(),
AttributeValue {
- bool: Some(token.valid),
+ bool: Some(access_token_data.valid),
..Default::default()
},
),
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
@@ -62,12 +62,12 @@
let message = request.into_inner();
let token_valid = match self
.client
- .get_token(message.user_id, message.device_id)
+ .get_access_token_data(message.user_id, message.device_id)
.await
{
- Ok(Some(access_token)) => constant_time_eq(
- access_token.token.as_bytes(),
- message.token.as_bytes(),
+ Ok(Some(access_token_data)) => constant_time_eq(
+ access_token_data.access_token.as_bytes(),
+ message.access_token.as_bytes(),
),
Ok(None) => false,
Err(Error::RusotoGet(RusotoError::Service(
diff --git a/services/identity/src/token.rs b/services/identity/src/token.rs
--- a/services/identity/src/token.rs
+++ b/services/identity/src/token.rs
@@ -9,26 +9,26 @@
Wallet,
}
-pub struct AccessToken {
+pub struct AccessTokenData {
pub user_id: String,
pub device_id: String,
- pub token: String,
+ pub access_token: String,
pub created: DateTime<Utc>,
pub auth_type: AuthType,
pub valid: bool,
}
-impl AccessToken {
+impl AccessTokenData {
pub fn new(
user_id: String,
device_id: String,
auth_type: AuthType,
rng: &mut (impl Rng + CryptoRng),
) -> Self {
- AccessToken {
+ AccessTokenData {
user_id,
device_id,
- token: Alphanumeric.sample_string(rng, 512),
+ access_token: Alphanumeric.sample_string(rng, 512),
created: Utc::now(),
auth_type,
valid: true,

File Metadata

Mime Type
text/plain
Expires
Tue, Dec 3, 6:40 AM (22 h, 4 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2610626
Default Alt Text
D4286.id13718.diff (5 KB)

Event Timeline