Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for #661 #662

Merged
merged 6 commits into from
Jul 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
110 changes: 55 additions & 55 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 14 additions & 10 deletions src/db/models/user.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{string::ToString, time::SystemTime};
use std::{fmt, time::SystemTime};

use argon2::{
password_hash::{
Expand Down Expand Up @@ -39,15 +39,19 @@ pub enum MFAMethod {
Email,
}

impl ToString for MFAMethod {
fn to_string(&self) -> String {
match self {
MFAMethod::None => "None".into(),
MFAMethod::OneTimePassword => "TOTP".into(),
MFAMethod::Web3 => "Web3".into(),
MFAMethod::Webauthn => "WebAuthn".into(),
MFAMethod::Email => "Email".into(),
}
impl fmt::Display for MFAMethod {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
"{}",
match self {
MFAMethod::None => "None",
MFAMethod::OneTimePassword => "TOTP",
MFAMethod::Web3 => "Web3",
MFAMethod::Webauthn => "WebAuthn",
MFAMethod::Email => "Email",
}
)
}
}

Expand Down
21 changes: 15 additions & 6 deletions src/grpc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ use tokio::{
},
time::sleep,
};
use tokio_stream::{wrappers::UnboundedReceiverStream, StreamExt};
use tokio_stream::wrappers::UnboundedReceiverStream;
use tonic::{
transport::{Certificate, ClientTlsConfig, Endpoint, Identity, Server, ServerTlsConfig},
Status,
Expand Down Expand Up @@ -381,10 +381,14 @@ pub async fn run_grpc_bidi_stream(
};
info!("Connected to proxy at {}", endpoint.uri());
let mut resp_stream = response.into_inner();
while let Some(received) = resp_stream.next().await {
info!("Received message from proxy");
match received {
Ok(received) => {
'message: loop {
match resp_stream.message().await {
Ok(None) => {
info!("stream was closed by the sender");
break 'message;
}
Ok(Some(received)) => {
info!("Received message from proxy");
let payload = match received.payload {
// rpc StartEnrollment (EnrollmentStartRequest) returns (EnrollmentStartResponse)
Some(core_request::Payload::EnrollmentStart(request)) => {
Expand Down Expand Up @@ -509,7 +513,12 @@ pub async fn run_grpc_bidi_stream(
};
tx.send(req).unwrap();
}
Err(err) => error!("stream error {err}"),
Err(err) => {
error!("stream error: {err}");
debug!("waiting 10s to re-establish the connection");
sleep(TEN_SECS).await;
break 'message;
}
}
}
}
Expand Down
Loading