Skip to content

Commit

Permalink
[Claims] Add act to claims (#61)
Browse files Browse the repository at this point in the history
* [Claims] Use the right serde nesting level for org and act

* undo
  • Loading branch information
kageiit authored Aug 19, 2024
1 parent 6ca766a commit a14a5ec
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions src/validators/authorizer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,13 @@ impl ActiveOrganization {
}
}

#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
pub struct Actor {
pub iss: String,
pub sid: Option<String>,
pub sub: String,
}

#[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
pub struct ClerkJwt {
pub azp: Option<String>,
Expand All @@ -41,7 +48,7 @@ pub struct ClerkJwt {
pub nbf: i32,
pub sid: Option<String>,
pub sub: String,
pub act: Option<String>,
pub act: Option<Actor>,
#[serde(flatten)]
pub org: Option<ActiveOrganization>,
}
Expand Down Expand Up @@ -177,7 +184,7 @@ mod tests {
azp: String,
iss: String,
sid: String,
act: String,
act: Actor,
org_id: String,
org_slug: String,
org_role: String,
Expand Down Expand Up @@ -216,11 +223,15 @@ mod tests {
iss: "issuer".to_string(),
nbf: current_time,
sid: "session_id".to_string(),
act: "actor".to_string(),
org_id: "org_id".to_string(),
org_slug: "org_slug".to_string(),
org_role: "org_role".to_string(),
org_permissions: vec!["org_permission".to_string()],
act: Actor {
iss: "actor_iss".to_string(),
sid: Some("actor_sid".to_string()),
sub: "actor_sub".to_string(),
},
};

let mut header = Header::new(Algorithm::RS256);
Expand Down Expand Up @@ -269,7 +280,11 @@ mod tests {
iss: "issuer".to_string(),
nbf: current_time as i32,
sid: Some("session_id".to_string()),
act: Some("actor".to_string()),
act: Some(Actor {
iss: "actor_iss".to_string(),
sid: Some("actor_sid".to_string()),
sub: "actor_sub".to_string(),
}),
org: Some(ActiveOrganization {
id: "org_id".to_string(),
slug: "org_slug".to_string(),
Expand Down

0 comments on commit a14a5ec

Please sign in to comment.