Skip to content

Commit

Permalink
Pass ClerkJWT
Browse files Browse the repository at this point in the history
  • Loading branch information
afroozeh committed Jul 31, 2024
1 parent fc6abc4 commit a568344
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/validators/authorizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use crate::{
use jsonwebtoken::{decode, decode_header, errors::Error as jwtError, Algorithm, DecodingKey, Header, Validation};
use std::{error::Error, fmt};

#[derive(Debug, Serialize, Deserialize, PartialEq)]
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
pub struct ActiveOrganization {
#[serde(rename = "org_id")]
pub id: String,
Expand All @@ -32,7 +32,7 @@ impl ActiveOrganization {
}
}

#[derive(Debug, Serialize, Deserialize, PartialEq)]
#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
pub struct ClerkJwt {
pub azp: Option<String>,
pub exp: i32,
Expand Down
5 changes: 3 additions & 2 deletions src/validators/axum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ where
self.service.poll_ready(cx)
}

fn call(&mut self, request: Request) -> Self::Future {
fn call(&mut self, mut request: Request) -> Self::Future {
let mut svc = self.service.clone();

// We want to skip running the validator if we are not able to find a matching path from the listed valid paths provided by the user
Expand Down Expand Up @@ -137,7 +137,8 @@ where
// Check if the request is authenticated
match authorizer.authorize(&req).await {
// We have authed request and can pass the user onto the next body
Ok(_) => {
Ok(jwt) => {
request.extensions_mut().insert(jwt);
let res = svc.call(request).await?;
return Ok(res);
}
Expand Down

0 comments on commit a568344

Please sign in to comment.