Skip to content

Commit

Permalink
fix: Derive Clone in JWT claim types (#323)
Browse files Browse the repository at this point in the history
  • Loading branch information
spencewenski authored Aug 11, 2024
1 parent 054e161 commit 4a2586a
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/middleware/http/auth/jwt/ietf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use typed_builder::TypedBuilder;
/// claim names are collected in the `custom` map.
/// See: <https://www.rfc-editor.org/rfc/rfc7519.html#section-4>
#[serde_as]
#[derive(Debug, Deserialize, Serialize, TypedBuilder)]
#[derive(Debug, Clone, Deserialize, Serialize, TypedBuilder)]
#[non_exhaustive]
pub struct Claims {
/// See: <https://www.rfc-editor.org/rfc/rfc7519.html#section-4.1.1>
Expand Down
3 changes: 1 addition & 2 deletions src/middleware/http/auth/jwt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ type BearerAuthHeader = TypedHeader<Authorization<Bearer>>;
/// the default will simply be a [serde_json::Value]. In all cases, the type can be overridden
/// by the consumer.
#[cfg_attr(feature = "open-api", derive(aide::OperationIo))]
// #[derive(Deserialize)]
#[derive(Deserialize, Serialize)]
#[non_exhaustive]
pub struct Jwt<C = Claims> {
Expand Down Expand Up @@ -149,7 +148,7 @@ where
/// See: <https://www.rfc-editor.org/rfc/rfc7519.html#section-4.1.2>
/// See: <https://openid.net/specs/openid-connect-core-1_0.html#IDToken>
// Intentionally not annotated with `#[non_exhaustive]`
#[derive(Debug, Deserialize, Serialize, PartialEq)]
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
#[serde(untagged)]
pub enum Subject {
Uri(Url),
Expand Down
4 changes: 2 additions & 2 deletions src/middleware/http/auth/jwt/openid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use crate::util::serde::{deserialize_from_str, serialize_to_str, UriOrString};
/// claim names are collected in the `custom` map.
/// See: <https://openid.net/specs/openid-connect-core-1_0.html#IDToken>
#[serde_as]
#[derive(Debug, Deserialize, Serialize, TypedBuilder)]
#[derive(Debug, Clone, Deserialize, Serialize, TypedBuilder)]
#[non_exhaustive]
pub struct Claims {
#[serde(rename = "iss")]
Expand Down Expand Up @@ -62,7 +62,7 @@ pub struct Claims {
}

// Intentionally not annotated with `#[non_exhaustive]`
#[derive(Debug, Deserialize, Serialize, PartialEq)]
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq)]
#[serde(untagged)]
pub enum Acr {
Uri(Url),
Expand Down

0 comments on commit 4a2586a

Please sign in to comment.