Skip to content

Commit

Permalink
Fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
TobiasDeBruijn committed Nov 3, 2024
1 parent 7a607ba commit d6b564c
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 31 deletions.
13 changes: 5 additions & 8 deletions server/wilford/src/espo/user.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use base64::Engine;
use espocrm_rs::{EspoApiClient, Method};
use reqwest::{Result, StatusCode};
use serde::Deserialize;
use tracing::{instrument, Instrument, trace, warn, warn_span};
use tracing::{instrument, trace, warn, warn_span, Instrument};

#[derive(Debug, Clone, Deserialize)]
#[serde(rename_all = "camelCase")]
Expand Down Expand Up @@ -55,7 +55,8 @@ impl EspoUser {
request = request.header("Espo-Authorization-Code", totp);
}

let result = request.send()
let result = request
.send()
.instrument(warn_span!("try_login::request"))
.await?;

Expand All @@ -74,9 +75,7 @@ impl EspoUser {
}

trace!("Deserializing EspoCRM response");
let payload: Response = result.json()
.instrument(warn_span!("deserialize"))
.await?;
let payload: Response = result.json().instrument(warn_span!("deserialize")).await?;
if payload.user.is_active {
Ok(LoginStatus::Ok(payload.user.id))
} else {
Expand All @@ -90,9 +89,7 @@ impl EspoUser {
}

trace!("Deserializing EspoCRM response");
let payload: Response = result.json()
.instrument(warn_span!("deserialize"))
.await?;
let payload: Response = result.json().instrument(warn_span!("deserialize")).await?;
if payload.message.eq("enterTotpCode") {
Ok(LoginStatus::SecondStepRequired)
} else {
Expand Down
17 changes: 5 additions & 12 deletions server/wilford/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,19 +98,12 @@ fn install_tracing() {
}

tracing_subscriber::registry()
.with(EnvFilter::from_default_env()
.add_directive("rustls=WARN"
.parse()
.expect("Invalid tracing directive")
)
.add_directive("rustls=WARN"
.parse()
.expect("Invalid tracing directive")
)
)
.with(layer()
.pretty()
.with(
EnvFilter::from_default_env()
.add_directive("rustls=WARN".parse().expect("Invalid tracing directive"))
.add_directive("rustls=WARN".parse().expect("Invalid tracing directive")),
)
.with(layer().pretty())
.with(ErrorLayer::default())
.init();
}
4 changes: 2 additions & 2 deletions server/wilford/src/routes/error.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::fmt;
use std::fmt::{Formatter, Write};
use actix_web::http::StatusCode;
use actix_web::ResponseError;
use std::fmt;
use std::fmt::{Formatter, Write};
use thiserror::Error;
use tracing_error::SpanTrace;

Expand Down
4 changes: 2 additions & 2 deletions server/wilford/src/routes/oauth/authorize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ pub async fn authorize(
&database,
query.scope.clone(),
query.state.clone(),
rt_to_at(&query.response_type),
response_to_authorization_type(&query.response_type),
query.nonce.clone(),
)
.await;
Expand All @@ -104,7 +104,7 @@ pub async fn authorize(
))))
}

fn rt_to_at(rt: &ResponseType) -> AuthorizationType {
fn response_to_authorization_type(rt: &ResponseType) -> AuthorizationType {
match rt {
ResponseType::Code => AuthorizationType::AuthorizationCode,
ResponseType::Token => AuthorizationType::Implicit,
Expand Down
12 changes: 5 additions & 7 deletions server/wilford/src/routes/well_known/jwks.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
use actix_web::web;
use base64::Engine;
use base64::prelude::BASE64_URL_SAFE_NO_PAD;
use rsa::{BigUint, RsaPublicKey};
use base64::Engine;
use rsa::pkcs8::DecodePublicKey;
use rsa::traits::PublicKeyParts;
use rsa::{BigUint, RsaPublicKey};
use serde::{Serialize, Serializer};

use crate::routes::appdata::WOidcPublicKey;
Expand Down Expand Up @@ -37,12 +37,10 @@ pub async fn jwks(oidc_public_key: WOidcPublicKey) -> WebResult<web::Json<Jwks>>
r#use: "sig".to_string(),
alg: "RS256".to_string(),
kid: "rsa".to_string(), // We dont have a kid
key_ops: vec![
"verify".to_string(),
],
key_ops: vec!["verify".to_string()],
// k: (**oidc_public_key).0.clone(),
n: public_key.n().clone(),
e: public_key.e().clone()
e: public_key.e().clone(),
}],
}))
}
Expand All @@ -54,4 +52,4 @@ where
let bytes = value.to_bytes_be();
let base64 = BASE64_URL_SAFE_NO_PAD.encode(bytes.as_slice());
serializer.serialize_str(&base64)
}
}

0 comments on commit d6b564c

Please sign in to comment.