Skip to content

Commit 3d8d846

Browse files
fix!: add a cfg to make the crypto backend for jwt configurable (#834)
1 parent 8e4624a commit 3d8d846

3 files changed

Lines changed: 13 additions & 2 deletions

File tree

.github/workflows/rust.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ jobs:
6565
- run: |
6666
rustup default stable
6767
rustup target add wasm32-unknown-unknown
68-
cargo build --target=wasm32-unknown-unknown --no-default-features
68+
cargo build --target=wasm32-unknown-unknown --no-default-features -F jwt-rust-crypto
6969
7070
clippy:
7171
runs-on: ubuntu-latest

Cargo.toml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ futures = { version = "0.3.15" }
4040
futures-core = { version = "0.3", optional = true }
4141
futures-util = { version = "0.3", optional = true }
4242
getrandom = { version = "0.2.15", features = ["js"] }
43-
jsonwebtoken = { version = "10", features = ["rust_crypto"] }
43+
jsonwebtoken = { version = "10", default-features = false, features = ["use_pem"] }
4444
http = "1.0.0"
4545
http-body = "1.0.0"
4646
http-body-util = "0.1.0"
@@ -99,13 +99,16 @@ default = [
9999
"tracing",
100100
"default-client",
101101
"rustls-ring",
102+
"jwt-rust-crypto",
102103
]
103104

104105
follow-redirect = ["tower-http/follow-redirect"]
105106
retry = ["tower/retry", "futures-util"]
106107
rustls = ["hyper-rustls"]
107108
rustls-ring = ["hyper-rustls/ring"]
108109
rustls-aws-lc-rs = ["hyper-rustls/aws-lc-rs"]
110+
jwt-aws-lc-rs = ["jsonwebtoken/aws_lc_rs"]
111+
jwt-rust-crypto = ["jsonwebtoken/rust_crypto"]
109112
rustls-webpki-tokio = ["hyper-rustls/webpki-tokio"]
110113
opentls = ["hyper-tls"]
111114
stream = ["futures-core", "futures-util"]

src/lib.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -295,6 +295,14 @@ pub use self::{
295295
page::Page,
296296
};
297297

298+
#[cfg(all(feature = "jwt-rust-crypto", feature = "jwt-aws-lc-rs"))]
299+
compile_error!(
300+
"feature \"jwt-rust-crypto\" and feature \"jwt-aws-lc-rs\" cannot be enabled at the same time"
301+
);
302+
303+
#[cfg(not(any(feature = "jwt-rust-crypto", feature = "jwt-aws-lc-rs")))]
304+
compile_error!("at least one of the features \"jwt-rust-crypto\" and feature \"jwt-aws-lc-rs\" must be enabled");
305+
298306
/// A convenience type with a default error type of [`Error`].
299307
pub type Result<T, E = error::Error> = std::result::Result<T, E>;
300308

0 commit comments

Comments
 (0)