Skip to content

Commit b28002a

Browse files
build(deps): bump jsonwebtoken from 10.4.0 to 11.0.0 (#2199)
* build(deps): bump jsonwebtoken from 10.4.0 to 11.0.0 Bumps [jsonwebtoken](https://github.com/Keats/jsonwebtoken) from 10.4.0 to 11.0.0. - [Changelog](https://github.com/Keats/jsonwebtoken/blob/master/CHANGELOG.md) - [Commits](Keats/jsonwebtoken@v10.4.0...v11.0.0) --- updated-dependencies: - dependency-name: jsonwebtoken dependency-version: 11.0.0 dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * fix(auth): use jsonwebtoken 11 KeyAlgorithm -> Algorithm conversion --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: SamTV12345 <40429738+samtv12345@users.noreply.github.com>
1 parent ca3d2c5 commit b28002a

3 files changed

Lines changed: 16 additions & 27 deletions

File tree

Cargo.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ http = "1.3.1"
108108
hyper-tls = { version = "0.6.0" }
109109
id3 = "1.17.0"
110110
indexmap = "2"
111-
jsonwebtoken = { version = "10.4.0", features = ["rust_crypto"] }
111+
jsonwebtoken = { version = "11.0.0", features = ["rust_crypto"] }
112112
libsqlite3-sys = { version = "0.37.0", features = ["bundled"] }
113113
maud = { version = "*", features = ["axum", "axum-core"] }
114114
mime_guess = "2.0.5"

crates/podfetch-web/src/auth_middleware.rs

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use common_infrastructure::error::ErrorSeverity::Warning;
1010
use common_infrastructure::error::{CustomError, CustomErrorInner};
1111
use common_infrastructure::http::get_async_sync_client;
1212
use common_infrastructure::runtime::ENVIRONMENT_SERVICE;
13-
use jsonwebtoken::jwk::{JwkSet, KeyAlgorithm};
13+
use jsonwebtoken::jwk::JwkSet;
1414
use jsonwebtoken::{Algorithm, DecodingKey, Validation, decode};
1515
use podfetch_domain::user::User;
1616
use serde_json::Value;
@@ -108,27 +108,6 @@ async fn handle_auth_internal(
108108
}
109109
}
110110

111-
fn from_key_alg_into_alg(value: KeyAlgorithm) -> Algorithm {
112-
match value {
113-
KeyAlgorithm::RS256 => Algorithm::RS256,
114-
KeyAlgorithm::RS384 => Algorithm::RS384,
115-
KeyAlgorithm::RS512 => Algorithm::RS512,
116-
KeyAlgorithm::ES256 => Algorithm::ES256,
117-
KeyAlgorithm::ES384 => Algorithm::ES384,
118-
KeyAlgorithm::PS256 => Algorithm::PS256,
119-
KeyAlgorithm::PS384 => Algorithm::PS384,
120-
KeyAlgorithm::PS512 => Algorithm::PS512,
121-
KeyAlgorithm::HS256 => Algorithm::HS256,
122-
KeyAlgorithm::HS384 => Algorithm::HS384,
123-
KeyAlgorithm::HS512 => Algorithm::HS512,
124-
KeyAlgorithm::EdDSA => Algorithm::EdDSA,
125-
KeyAlgorithm::RSA1_5 => Algorithm::ES256,
126-
KeyAlgorithm::RSA_OAEP => Algorithm::RS256,
127-
KeyAlgorithm::RSA_OAEP_256 => Algorithm::RS256,
128-
KeyAlgorithm::UNKNOWN_ALGORITHM => Algorithm::ES256,
129-
}
130-
}
131-
132111
impl AuthFilter {
133112
fn map_auth_error(error: AuthControllerError<CustomError>) -> CustomError {
134113
match error {
@@ -217,8 +196,18 @@ impl AuthFilter {
217196
}?;
218197

219198
let key = DecodingKey::from_jwk(first_jwk).unwrap();
220-
let alg = first_jwk.common.key_algorithm.unwrap();
221-
let mut validation = Validation::new(from_key_alg_into_alg(alg));
199+
let alg = match first_jwk
200+
.common
201+
.key_algorithm
202+
.and_then(|alg| Algorithm::try_from(alg).ok())
203+
{
204+
Some(alg) => Ok(alg),
205+
None => {
206+
tracing::error!("JWK has no supported signing algorithm");
207+
Err(CustomError::from(CustomErrorInner::Forbidden(Warning)))
208+
}
209+
}?;
210+
let mut validation = Validation::new(alg);
222211
let mut aud_hashset = HashSet::new();
223212
aud_hashset.insert(
224213
environment

0 commit comments

Comments
 (0)