This is an automated email from the ASF dual-hosted git repository.
tisonkun pushed a commit to branch opt-jwt
in repository https://gitbox.apache.org/repos/asf/opendal-reqsign.git
The following commit(s) were added to refs/heads/opt-jwt by this push:
new c26a996 feature flags
c26a996 is described below
commit c26a99646fe086013832cf0fef95a2e5903d2385
Author: tison <[email protected]>
AuthorDate: Sat Jul 4 09:14:52 2026 +0800
feature flags
Signed-off-by: tison <[email protected]>
---
Cargo.toml | 1 -
context/jwt/Cargo.toml | 36 ----------------------
core/Cargo.toml | 9 ++++++
context/jwt/src/lib.rs => core/src/jwt.rs | 4 +--
core/src/lib.rs | 2 ++
services/azure-storage/Cargo.toml | 2 +-
.../src/provide_credential/client_certificate.rs | 2 +-
services/google/Cargo.toml | 2 +-
services/google/src/sign_request.rs | 2 +-
9 files changed, 17 insertions(+), 43 deletions(-)
diff --git a/Cargo.toml b/Cargo.toml
index f9a255e..92632ed 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -36,7 +36,6 @@ reqsign-file-read-tokio = { version = "3.0.1", path =
"context/file-read-tokio"
reqsign-google = { version = "3.0.1", path = "services/google" }
reqsign-http-send-reqwest = { version = "4.0.1", path =
"context/http-send-reqwest" }
reqsign-huaweicloud-obs = { version = "3.0.1", path =
"services/huaweicloud-obs" }
-reqsign-jwt = { version = "0.1.0", path = "context/jwt" }
reqsign-oracle = { version = "3.0.1", path = "services/oracle" }
reqsign-tencent-cos = { version = "3.0.1", path = "services/tencent-cos" }
reqsign-volcengine-tos = { version = "3.0.1", path = "services/volcengine-tos"
}
diff --git a/context/jwt/Cargo.toml b/context/jwt/Cargo.toml
deleted file mode 100644
index 9124319..0000000
--- a/context/jwt/Cargo.toml
+++ /dev/null
@@ -1,36 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-
-[package]
-name = "reqsign-jwt"
-version = "0.1.0"
-
-categories = ["cryptography"]
-description = "JWT-based signing implementation for reqsign."
-keywords = ["jwt", "reqsign"]
-
-edition.workspace = true
-license.workspace = true
-repository.workspace = true
-rust-version.workspace = true
-
-[dependencies]
-base64 = { workspace = true }
-reqsign-core = { workspace = true }
-rsa = { workspace = true }
-serde = { workspace = true }
-serde_json = { workspace = true }
diff --git a/core/Cargo.toml b/core/Cargo.toml
index 4c50cda..0aeb6a3 100644
--- a/core/Cargo.toml
+++ b/core/Cargo.toml
@@ -27,6 +27,10 @@ license.workspace = true
repository.workspace = true
rust-version.workspace = true
+[features]
+default = []
+jwt = ["dep:rsa", "dep:serde", "dep:serde_json"]
+
[dependencies]
anyhow = { workspace = true }
base64 = { workspace = true }
@@ -42,6 +46,11 @@ percent-encoding = { workspace = true }
sha1 = { workspace = true }
sha2 = { workspace = true }
+# Optional dependencies
+rsa = { workspace = true, optional = true }
+serde = { workspace = true, optional = true }
+serde_json = { workspace = true, optional = true }
+
[target.'cfg(target_os = "windows")'.dependencies]
windows-sys = { version = "0.61.0", features = [
"Win32_Foundation",
diff --git a/context/jwt/src/lib.rs b/core/src/jwt.rs
similarity index 97%
rename from context/jwt/src/lib.rs
rename to core/src/jwt.rs
index 15d7c18..df3948e 100644
--- a/context/jwt/src/lib.rs
+++ b/core/src/jwt.rs
@@ -27,7 +27,7 @@ use rsa::sha2::Sha256;
use rsa::signature::{RandomizedSigner, SignatureEncoding};
use serde::Serialize;
-use reqsign_core::{Error, Result};
+use crate::{Error, Result};
/// Encode a JWS compact JWT using the RS256 algorithm.
///
@@ -128,7 +128,7 @@ mod tests {
.decode(parts[0])
.map_err(|e| Error::unexpected("failed to decode JWT
header").with_source(e))?,
)
- .map_err(|e| Error::unexpected("failed to parse JWT
header").with_source(e))?;
+ .map_err(|e| Error::unexpected("failed to parse JWT
header").with_source(e))?;
assert_eq!(
header,
json!({
diff --git a/core/src/lib.rs b/core/src/lib.rs
index dd827da..00b96f5 100644
--- a/core/src/lib.rs
+++ b/core/src/lib.rs
@@ -153,6 +153,8 @@
pub mod error;
mod futures_util;
pub mod hash;
+#[cfg(all(not(target_arch = "wasm32"), feature = "jwt"))]
+pub mod jwt;
pub mod time;
pub mod utils;
diff --git a/services/azure-storage/Cargo.toml
b/services/azure-storage/Cargo.toml
index 984ea47..00cafd0 100644
--- a/services/azure-storage/Cargo.toml
+++ b/services/azure-storage/Cargo.toml
@@ -42,7 +42,7 @@ sha1 = { workspace = true }
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
pem = { workspace = true }
rsa = { workspace = true }
-reqsign-jwt = { workspace = true }
+reqsign-core = { workspace = true, features = ["jwt"] }
[dev-dependencies]
env_logger = { workspace = true }
diff --git
a/services/azure-storage/src/provide_credential/client_certificate.rs
b/services/azure-storage/src/provide_credential/client_certificate.rs
index 2c63a90..314e63c 100644
--- a/services/azure-storage/src/provide_credential/client_certificate.rs
+++ b/services/azure-storage/src/provide_credential/client_certificate.rs
@@ -184,7 +184,7 @@ impl ClientCertificateCredentialProvider {
x5t: self.calculate_thumbprint(cert_der),
};
- reqsign_jwt::encode_rs256(&header, &claims, private_key)
+ reqsign_core::jwt::encode_rs256(&header, &claims, private_key)
}
/// Exchange client assertion for access token
diff --git a/services/google/Cargo.toml b/services/google/Cargo.toml
index 18d657d..c23a863 100644
--- a/services/google/Cargo.toml
+++ b/services/google/Cargo.toml
@@ -39,7 +39,7 @@ serde_json = { workspace = true }
tokio = { workspace = true, features = ["time"] }
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
-reqsign-jwt = { workspace = true }
+reqsign-core = { workspace = true, features = ["jwt"] }
[dev-dependencies]
bytes = { workspace = true }
diff --git a/services/google/src/sign_request.rs
b/services/google/src/sign_request.rs
index f1af295..dcec4e9 100644
--- a/services/google/src/sign_request.rs
+++ b/services/google/src/sign_request.rs
@@ -147,7 +147,7 @@ impl RequestSigner {
debug!("exchanging service account for token with scope: {scope}");
- let jwt = reqsign_jwt::encode_rs256_pem(
+ let jwt = reqsign_core::jwt::encode_rs256_pem(
&JwtHeader::rs256(),
&Claims::new(&sa.client_email, &scope),
sa.private_key.as_bytes(),