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

Pass ClerkJWT #53

Merged
merged 1 commit into from
Aug 4, 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
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
Loading