From f835fe4f5d33318bbee4f2185290cdda6fc2b3cc Mon Sep 17 00:00:00 2001 From: Erik Tesar Date: Thu, 4 Apr 2024 20:49:50 +0200 Subject: [PATCH] fix: remove `PartialEq` implementation from `JsonWebKey` fixes #95 --- src/jwk.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/jwk.rs b/src/jwk.rs index 828f7b7..bdfeada 100644 --- a/src/jwk.rs +++ b/src/jwk.rs @@ -68,6 +68,18 @@ pub use self::{ /// an abstract representation of all possible key types. The [`JsonWebKeyType`] /// enum is used to specialize on concrete key type. /// +/// # Comparison and equality +/// +/// It is not defined how to determine if a [`JsonWebKey`] is [equal](PartialEq) +/// to another. Therefore, [`JsonWebKey`] *does not* implement [`PartialEq`]. +/// If you want to compare a [`JsonWebKey`], you should either use something +/// like the [`kid`](JsonWebKey::key_id) parameter or a [`Thumbprint`] of +/// the key (or ideally, a [`Thumbprint`] as [`kid`](JsonWebKey::key_id)). +/// +/// You should *avoid* comparing the serialized form of a [`JsonWebKey`] as it +/// may contain optional parameters, which may not always be present and would +/// lead to unexpected results. +/// /// # Examples /// /// Parse a JsonWebKey from its json representation: @@ -184,7 +196,7 @@ pub use self::{ /// [RFC 7517]: /// [section 6 of RFC 7518]: /// [IANA `Json Web Key Parameters` registry]: -#[derive(Debug, PartialEq, Eq, Deserialize, Serialize, Clone)] +#[derive(Debug, Deserialize, Serialize, Clone)] pub struct JsonWebKey { /// Additional members in the JWK as permitted by the fourth paragraph of /// [section 4]