From a7d2830dd123f9f615eb1b6d5d26fa5f4bed24a1 Mon Sep 17 00:00:00 2001 From: Vladislav Manchev <3009538+blablacio@users.noreply.github.com> Date: Fri, 3 Nov 2023 21:11:27 +0200 Subject: [PATCH] - Update jsonwebtoken to latest version - Update key algorithm handling when initializing key data --- jwt-authorizer/Cargo.toml | 2 +- jwt-authorizer/src/jwks/mod.rs | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/jwt-authorizer/Cargo.toml b/jwt-authorizer/Cargo.toml index 5270d7d..679172c 100644 --- a/jwt-authorizer/Cargo.toml +++ b/jwt-authorizer/Cargo.toml @@ -15,7 +15,7 @@ chrono = { version = "0.4", optional = true } futures-util = "0.3" futures-core = "0.3" headers = "0.3" -jsonwebtoken = "8.3" +jsonwebtoken = "9.1.0" http = "0.2" pin-project = "1.0" reqwest = { version = "0.11", default-features = false, features = ["json"] } diff --git a/jwt-authorizer/src/jwks/mod.rs b/jwt-authorizer/src/jwks/mod.rs index eac2b11..4d07f06 100644 --- a/jwt-authorizer/src/jwks/mod.rs +++ b/jwt-authorizer/src/jwks/mod.rs @@ -1,4 +1,4 @@ -use std::sync::Arc; +use std::{str::FromStr, sync::Arc}; use jsonwebtoken::{jwk::Jwk, Algorithm, DecodingKey, Header}; @@ -29,7 +29,7 @@ impl KeyData { pub fn from_jwk(key: &Jwk) -> Result { Ok(KeyData { kid: key.common.key_id.clone(), - alg: vec![key.common.algorithm.unwrap_or(Algorithm::RS256)], // TODO: is this good default? + alg: vec![Algorithm::from_str(key.common.key_algorithm.unwrap().to_string().as_str())?], key: DecodingKey::from_jwk(key)?, }) }