Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3115406
D4352.id13853.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
5 KB
Referenced Files
None
Subscribers
None
D4352.id13853.diff
View Options
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
@@ -34,6 +34,7 @@
pake_login_response::Data::PakeCredentialResponse, LoginRequest,
LoginResponse,
PakeCredentialRequestAndUserId as PakeCredentialRequestAndUserIdStruct,
+ PakeLoginRequest as PakeLoginRequestStruct,
PakeLoginResponse as PakeLoginResponseStruct, RegistrationRequest,
RegistrationResponse, VerifyUserTokenRequest, VerifyUserTokenResponse,
WalletLoginRequest as WalletLoginRequestStruct,
@@ -81,46 +82,103 @@
) -> Result<Response<Self::LoginUserStream>, Status> {
let mut in_stream = request.into_inner();
let (tx, rx) = mpsc::channel(1);
+ let config = self.config.clone();
let client = self.client.clone();
tokio::spawn(async move {
+ let mut user_id: String = String::new();
+ let mut device_id: String = String::new();
+ let mut server_login: Option<ServerLogin<Cipher>> = None;
let mut num_messages_received = 0;
while let Some(message) = in_stream.next().await {
match message {
- Ok(login_request) => {
- if let Some(data) = login_request.data {
- match data {
- WalletLoginRequest(req) => {
- if let Err(e) = tx
- .send(
- wallet_login_helper(
- client,
- req,
- &mut OsRng,
- num_messages_received,
- )
- .await,
- )
- .await
- {
- error!("Response was dropped: {}", e);
- }
- break;
- }
- PakeLoginRequest(_) => unimplemented!(),
- }
- } else {
- error!("Received empty login request");
- if let Err(e) = tx
- .send(Err(Status::invalid_argument("invalid message")))
+ Ok(LoginRequest {
+ data: Some(WalletLoginRequest(req)),
+ }) => {
+ if let Err(e) = tx
+ .send(
+ wallet_login_helper(
+ client,
+ req,
+ &mut OsRng,
+ num_messages_received,
+ )
+ .await,
+ )
+ .await
+ {
+ error!("Response was dropped: {}", e);
+ }
+ break;
+ }
+ Ok(LoginRequest {
+ data:
+ Some(PakeLoginRequest(PakeLoginRequestStruct {
+ data:
+ Some(PakeCredentialRequestAndUserId(
+ pake_credential_request_and_user_id,
+ )),
+ })),
+ }) => {
+ if let Err(e) = tx
+ .send(
+ pake_login_start(
+ config.clone(),
+ client.clone(),
+ &pake_credential_request_and_user_id.user_id,
+ &pake_credential_request_and_user_id.pake_credential_request,
+ num_messages_received,
+ PakeWorkflow::Login,
+ )
.await
- {
- error!("Response was dropped: {}", e);
- }
+ .map(|pake_login_response_and_server_login| {
+ server_login = Some(pake_login_response_and_server_login.1);
+ LoginResponse {
+ data: Some(PakeLoginResponse(
+ pake_login_response_and_server_login.0,
+ )),
+ }
+ }),
+ )
+ .await
+ {
+ error!("Response was dropped: {}", e);
break;
}
+ user_id = pake_credential_request_and_user_id.user_id;
+ device_id = pake_credential_request_and_user_id.device_id;
+ }
+ Ok(LoginRequest {
+ data:
+ Some(PakeLoginRequest(PakeLoginRequestStruct {
+ data:
+ Some(PakeCredentialFinalization(pake_credential_finalization)),
+ })),
+ }) => {
+ if let Err(e) = tx
+ .send(
+ pake_login_finish(
+ &user_id,
+ &device_id,
+ client,
+ server_login,
+ &pake_credential_finalization,
+ &mut OsRng,
+ num_messages_received,
+ PakeWorkflow::Login,
+ )
+ .await
+ .map(|pake_login_response| LoginResponse {
+ data: Some(PakeLoginResponse(pake_login_response)),
+ }),
+ )
+ .await
+ {
+ error!("Response was dropped: {}", e);
+ }
+ break;
}
- Err(e) => {
- error!("Received an unexpected error: {}", e);
+ unexpected => {
+ error!("Received an unexpected Result: {:?}", unexpected);
if let Err(e) = tx.send(Err(Status::unknown("unknown error"))).await
{
error!("Response was dropped: {}", e);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Nov 1, 9:28 PM (22 h, 7 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2401817
Default Alt Text
D4352.id13853.diff (5 KB)
Attached To
Mode
D4352: [services][identity] PAKE login
Attached
Detach File
Event Timeline
Log In to Comment