Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,5 +51,12 @@ jobs:
- name: Run Integration Tests
run: RUST_BACKTRACE=1 cargo test --features integration-tests

- name: Run Integration Tests with aws-lc-rs
run: >
RUST_BACKTRACE=1
cargo test
--no-default-features
--features integration-tests,spiffe-types,workload-api,aws-lc-rs

- name: Clean up SPIRE
run: .github/workflows/scripts/cleanup-spire.sh
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,6 @@ members = [
"spire-api",
]
resolver = "2"

[patch.crates-io]
jsonwebtoken = { git = "https://github.com/dsykes16/jsonwebtoken.git", branch = "add-dangerous-decode" }
6 changes: 4 additions & 2 deletions spiffe/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ url = "2"
asn1 = { package = "simple_asn1", version = "0.6" }
x509-parser = "0.18"
pkcs8 = "0.10"
jsonwebtoken = "9"
jsonwebtoken = "10"
serde = { version = "1", features = ["derive"] }
serde_json = "1"
zeroize = { version = "1", features = ["zeroize_derive"] }
Expand Down Expand Up @@ -55,7 +55,9 @@ prost-build = "0.14"
anyhow = "1"

[features]
default = ["spiffe-types", "workload-api"]
default = ["spiffe-types", "workload-api", "rust-crypto"]
spiffe-types = []
workload-api = ["prost", "prost-types", "tokio", "tokio-stream", "tower", "tokio-util", "log"]
integration-tests = []
aws-lc-rs = ["jsonwebtoken/aws_lc_rs"]
rust-crypto = ["jsonwebtoken/rust_crypto"]
16 changes: 3 additions & 13 deletions spiffe/src/svid/jwt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
use std::str::FromStr;

use jsonwebtoken::jwk::Jwk;
use jsonwebtoken::{Algorithm, DecodingKey, Validation};
use jsonwebtoken::{Algorithm, DecodingKey};
use serde::{de, Deserialize, Deserializer, Serialize};
use thiserror::Error;
use zeroize::Zeroize;
Expand Down Expand Up @@ -237,12 +237,8 @@ impl FromStr for JwtSvid {
/// IMPORTANT: For parsing and validating the signature of untrusted tokens, use `parse_and_validate` method.
fn from_str(token: &str) -> Result<Self, Self::Err> {
// decode token without signature or expiration validation
let mut validation = Validation::default();
// We later on validate audience separately with `parse_and_validate`
validation.validate_aud = false;
validation.insecure_disable_signature_validation();
let token_data =
jsonwebtoken::decode::<Claims>(token, &DecodingKey::from_secret(&[]), &validation)?;
let token_data = jsonwebtoken::dangerous::insecure_decode::<Claims>(token)?;

let claims = token_data.claims;
let spiffe_id = SpiffeId::from_str(&claims.sub)?;
Expand Down Expand Up @@ -503,13 +499,7 @@ mod test {
typ,
alg,
kid,
cty: None,
jku: None,
x5u: None,
x5c: None,
x5t: None,
jwk: None,
x5t_s256: None,
..Default::default()
};
encode(&header, &claims, encoding_key).unwrap()
}
Expand Down
Loading