Skip to content

Commit 61b8c1e

Browse files
authored
Fix CI (#322)
* Update docs and tests for MSRV 1.67 As of #303 * Address all clippy issues * Apply `cargo fmt`
1 parent d17051c commit 61b8c1e

File tree

7 files changed

+21
-52
lines changed

7 files changed

+21
-52
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
include:
3939
- build: pinned
4040
os: ubuntu-20.04
41-
rust: 1.59.0
41+
rust: 1.67.0
4242
- build: stable
4343
os: ubuntu-20.04
4444
rust: stable

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ repository = "https://github.com/Keats/jsonwebtoken"
1010
keywords = ["jwt", "api", "token", "jwk"]
1111
edition = "2021"
1212
include = ["src/**/*", "benches/**/*", "tests/**/*", "LICENSE", "README.md", "CHANGELOG.md"]
13-
rust-version = "1.56.0"
13+
rust-version = "1.67.0"
1414

1515
[dependencies]
1616
serde_json = "1.0"

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jsonwebtoken = "8"
1414
serde = {version = "1.0", features = ["derive"] }
1515
```
1616

17-
The minimum required Rust version is 1.56.
17+
The minimum required Rust version (MSRV) is 1.67.
1818

1919
## Algorithms
2020
This library currently supports the following:

src/algorithms.rs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ pub(crate) enum AlgorithmFamily {
1212

1313
/// The algorithms supported for signing/verifying JWTs
1414
#[allow(clippy::upper_case_acronyms)]
15-
#[derive(Debug, PartialEq, Eq, Hash, Copy, Clone, Serialize, Deserialize)]
15+
#[derive(Debug, Default, PartialEq, Eq, Hash, Copy, Clone, Serialize, Deserialize)]
1616
pub enum Algorithm {
1717
/// HMAC using SHA-256
18+
#[default]
1819
HS256,
1920
/// HMAC using SHA-384
2021
HS384,
@@ -44,12 +45,6 @@ pub enum Algorithm {
4445
EdDSA,
4546
}
4647

47-
impl Default for Algorithm {
48-
fn default() -> Self {
49-
Algorithm::HS256
50-
}
51-
}
52-
5348
impl FromStr for Algorithm {
5449
type Err = Error;
5550
fn from_str(s: &str) -> Result<Self> {

src/jwk.rs

Lines changed: 14 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
#![allow(missing_docs)]
2-
///! This crate contains types only for working JWK and JWK Sets
3-
///! This is only meant to be used to deal with public JWK, not generate ones.
4-
///! Most of the code in this file is taken from https://github.com/lawliet89/biscuit but
5-
/// tweaked to remove the private bits as it's not the goal for this crate currently.
6-
///!
2+
//! This crate contains types only for working JWK and JWK Sets
3+
//! This is only meant to be used to deal with public JWK, not generate ones.
4+
//! Most of the code in this file is taken from https://github.com/lawliet89/biscuit but
5+
//! tweaked to remove the private bits as it's not the goal for this crate currently.
76
use crate::Algorithm;
87
use serde::{de, Deserialize, Deserializer, Serialize, Serializer};
98
use std::fmt;
@@ -194,24 +193,20 @@ pub struct CommonParameters {
194193

195194
/// Key type value for an Elliptic Curve Key.
196195
/// This single value enum is a workaround for Rust not supporting associated constants.
197-
#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize, Hash)]
196+
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Hash)]
198197
pub enum EllipticCurveKeyType {
199198
/// Key type value for an Elliptic Curve Key.
199+
#[default]
200200
EC,
201201
}
202202

203-
impl Default for EllipticCurveKeyType {
204-
fn default() -> Self {
205-
EllipticCurveKeyType::EC
206-
}
207-
}
208-
209203
/// Type of cryptographic curve used by a key. This is defined in
210204
/// [RFC 7518 #7.6](https://tools.ietf.org/html/rfc7518#section-7.6)
211-
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize, Hash)]
205+
#[derive(Clone, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Hash)]
212206
pub enum EllipticCurve {
213207
/// P-256 curve
214208
#[serde(rename = "P-256")]
209+
#[default]
215210
P256,
216211
/// P-384 curve
217212
#[serde(rename = "P-384")]
@@ -224,12 +219,6 @@ pub enum EllipticCurve {
224219
Ed25519,
225220
}
226221

227-
impl Default for EllipticCurve {
228-
fn default() -> Self {
229-
EllipticCurve::P256
230-
}
231-
}
232-
233222
/// Parameters for an Elliptic Curve Key
234223
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize, Default, Hash)]
235224
pub struct EllipticCurveKeyParameters {
@@ -250,18 +239,13 @@ pub struct EllipticCurveKeyParameters {
250239

251240
/// Key type value for an RSA Key.
252241
/// This single value enum is a workaround for Rust not supporting associated constants.
253-
#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize, Hash)]
242+
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Hash)]
254243
pub enum RSAKeyType {
255244
/// Key type value for an RSA Key.
245+
#[default]
256246
RSA,
257247
}
258248

259-
impl Default for RSAKeyType {
260-
fn default() -> Self {
261-
RSAKeyType::RSA
262-
}
263-
}
264-
265249
/// Parameters for a RSA Key
266250
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize, Default, Hash)]
267251
pub struct RSAKeyParameters {
@@ -280,19 +264,14 @@ pub struct RSAKeyParameters {
280264

281265
/// Key type value for an Octet symmetric key.
282266
/// This single value enum is a workaround for Rust not supporting associated constants.
283-
#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize, Hash)]
267+
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Hash)]
284268
pub enum OctetKeyType {
285269
/// Key type value for an Octet symmetric key.
286270
#[serde(rename = "oct")]
271+
#[default]
287272
Octet,
288273
}
289274

290-
impl Default for OctetKeyType {
291-
fn default() -> Self {
292-
OctetKeyType::Octet
293-
}
294-
}
295-
296275
/// Parameters for an Octet Key
297276
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize, Default, Hash)]
298277
pub struct OctetKeyParameters {
@@ -306,19 +285,14 @@ pub struct OctetKeyParameters {
306285

307286
/// Key type value for an Octet Key Pair.
308287
/// This single value enum is a workaround for Rust not supporting associated constants.
309-
#[derive(Clone, Copy, Debug, Eq, PartialEq, Serialize, Deserialize, Hash)]
288+
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Serialize, Deserialize, Hash)]
310289
pub enum OctetKeyPairType {
311290
/// Key type value for an Octet Key Pair.
312291
#[serde(rename = "OKP")]
292+
#[default]
313293
OctetKeyPair,
314294
}
315295

316-
impl Default for OctetKeyPairType {
317-
fn default() -> Self {
318-
OctetKeyPairType::OctetKeyPair
319-
}
320-
}
321-
322296
/// Parameters for an Octet Key Pair
323297
#[derive(Clone, Debug, Eq, PartialEq, Serialize, Deserialize, Default, Hash)]
324298
pub struct OctetKeyPairParameters {

src/pem/decoder.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ impl PemEncodedKey {
5858
Err(_) => return Err(ErrorKind::InvalidKeyFormat.into()),
5959
};
6060

61-
match content.tag().as_ref() {
61+
match content.tag() {
6262
// This handles a PKCS#1 RSA Private key
6363
"RSA PRIVATE KEY" => Ok(PemEncodedKey {
6464
content: content.into_contents(),

src/validation.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ pub(crate) fn validate(claims: ClaimsForValidation, options: &Validation) -> Res
228228
}
229229
}
230230

231-
if (options.validate_exp || options.validate_nbf) {
231+
if options.validate_exp || options.validate_nbf {
232232
let now = get_current_timestamp();
233233

234234
if matches!(claims.exp, TryParse::Parsed(exp) if options.validate_exp && exp < now - options.leeway)

0 commit comments

Comments
 (0)