rustfmt and simplify
This commit is contained in:
parent
6022dd7cf7
commit
a406f059e3
|
@ -11,7 +11,8 @@ struct Claims {
|
||||||
|
|
||||||
pub async fn validate_token(token: &str) -> Result<bool, ServiceError> {
|
pub async fn validate_token(token: &str) -> Result<bool, ServiceError> {
|
||||||
let domain = std::env::var("DOMAIN").expect("DOMAIN must be set");
|
let domain = std::env::var("DOMAIN").expect("DOMAIN must be set");
|
||||||
let jwks = fetch_jwks(&format!("{}{}", domain.as_str(), ".well-known/jwks.json")).await
|
let jwks = fetch_jwks(&format!("{}{}", domain.as_str(), ".well-known/jwks.json"))
|
||||||
|
.await
|
||||||
.expect("failed to fetch jwks");
|
.expect("failed to fetch jwks");
|
||||||
let validations = vec![Validation::Issuer(domain), Validation::SubjectPresent];
|
let validations = vec![Validation::Issuer(domain), Validation::SubjectPresent];
|
||||||
let kid = match token_kid(&token) {
|
let kid = match token_kid(&token) {
|
||||||
|
@ -24,7 +25,5 @@ pub async fn validate_token(token: &str) -> Result<bool, ServiceError> {
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn fetch_jwks(uri: &str) -> anyhow::Result<JWKS> {
|
async fn fetch_jwks(uri: &str) -> anyhow::Result<JWKS> {
|
||||||
let res = reqwest::get(uri).await?;
|
Ok(reqwest::get(uri).await?.json::<JWKS>().await?)
|
||||||
let val = res.json::<JWKS>().await?;
|
|
||||||
return Ok(val);
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,4 +18,3 @@ pub struct NewUser<'a> {
|
||||||
pub email: &'a str,
|
pub email: &'a str,
|
||||||
pub created_at: chrono::NaiveDateTime,
|
pub created_at: chrono::NaiveDateTime,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue