You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@opendal.apache.org by ti...@apache.org on 2026/07/01 23:41:29 UTC
(opendal-reqsign) 01/01: refactor: make reqsign-jwt optional
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
commit 718c670c4af7220a50dc6c2491603723e5e5bc61
Author: tison <wa...@gmail.com>
AuthorDate: Thu Jul 2 07:41:18 2026 +0800
refactor: make reqsign-jwt optional
Signed-off-by: tison <wa...@gmail.com>
---
Cargo.toml | 1 +
{services/google => context/jwt}/Cargo.toml | 24 ++++++----------------
core/src/jwt.rs => context/jwt/src/lib.rs | 4 ++--
core/Cargo.toml | 5 -----
core/src/lib.rs | 2 --
services/azure-storage/Cargo.toml | 1 +
.../src/provide_credential/client_certificate.rs | 2 +-
services/google/Cargo.toml | 1 +
services/google/src/sign_request.rs | 4 ++--
9 files changed, 14 insertions(+), 30 deletions(-)
diff --git a/Cargo.toml b/Cargo.toml
index 20c35c1..190eefc 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -36,6 +36,7 @@ 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/services/google/Cargo.toml b/context/jwt/Cargo.toml
similarity index 61%
copy from services/google/Cargo.toml
copy to context/jwt/Cargo.toml
index edaa389..9124319 100644
--- a/services/google/Cargo.toml
+++ b/context/jwt/Cargo.toml
@@ -16,10 +16,12 @@
# under the License.
[package]
-name = "reqsign-google"
-version = "3.0.1"
+name = "reqsign-jwt"
+version = "0.1.0"
-description = "Google Cloud Platform signing implementation for reqsign."
+categories = ["cryptography"]
+description = "JWT-based signing implementation for reqsign."
+keywords = ["jwt", "reqsign"]
edition.workspace = true
license.workspace = true
@@ -27,22 +29,8 @@ repository.workspace = true
rust-version.workspace = true
[dependencies]
-form_urlencoded = { workspace = true }
-http = { workspace = true }
-log = { workspace = true }
-percent-encoding = { workspace = true }
-reqsign-aws-v4 = { workspace = true }
+base64 = { workspace = true }
reqsign-core = { workspace = true }
rsa = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
-tokio = { workspace = true, features = ["time"] }
-
-[dev-dependencies]
-bytes = { workspace = true }
-dotenvy = { workspace = true }
-env_logger = { workspace = true }
-reqsign-file-read-tokio = { workspace = true }
-reqsign-http-send-reqwest = { workspace = true }
-reqwest = { workspace = true, features = ["default-tls"] }
-tokio = { workspace = true, features = ["full"] }
diff --git a/core/src/jwt.rs b/context/jwt/src/lib.rs
similarity index 97%
rename from core/src/jwt.rs
rename to context/jwt/src/lib.rs
index 413ff8f..6f1ed79 100644
--- a/core/src/jwt.rs
+++ b/context/jwt/src/lib.rs
@@ -27,7 +27,7 @@ use rsa::sha2::Sha256;
use rsa::signature::{RandomizedSigner, SignatureEncoding};
use serde::Serialize;
-use crate::{Error, Result};
+use reqsign_core::{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/Cargo.toml b/core/Cargo.toml
index 0437cfc..4c50cda 100644
--- a/core/Cargo.toml
+++ b/core/Cargo.toml
@@ -42,11 +42,6 @@ percent-encoding = { workspace = true }
sha1 = { workspace = true }
sha2 = { workspace = true }
-[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
-rsa = { workspace = true }
-serde = { workspace = true }
-serde_json = { workspace = true }
-
[target.'cfg(target_os = "windows")'.dependencies]
windows-sys = { version = "0.61.0", features = [
"Win32_Foundation",
diff --git a/core/src/lib.rs b/core/src/lib.rs
index 9ed35c5..dd827da 100644
--- a/core/src/lib.rs
+++ b/core/src/lib.rs
@@ -153,8 +153,6 @@
pub mod error;
mod futures_util;
pub mod hash;
-#[cfg(not(target_arch = "wasm32"))]
-pub mod jwt;
pub mod time;
pub mod utils;
diff --git a/services/azure-storage/Cargo.toml b/services/azure-storage/Cargo.toml
index b9bb058..6b86e9b 100644
--- a/services/azure-storage/Cargo.toml
+++ b/services/azure-storage/Cargo.toml
@@ -35,6 +35,7 @@ http = { workspace = true }
log = { workspace = true }
percent-encoding = { workspace = true }
reqsign-core = { workspace = true }
+reqsign-jwt = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
sha1 = { 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 314e63c..2c63a90 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_core::jwt::encode_rs256(&header, &claims, private_key)
+ reqsign_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 edaa389..5b9ce8e 100644
--- a/services/google/Cargo.toml
+++ b/services/google/Cargo.toml
@@ -33,6 +33,7 @@ log = { workspace = true }
percent-encoding = { workspace = true }
reqsign-aws-v4 = { workspace = true }
reqsign-core = { workspace = true }
+reqsign-jwt = { workspace = true }
rsa = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
diff --git a/services/google/src/sign_request.rs b/services/google/src/sign_request.rs
index 583382e..f1af295 100644
--- a/services/google/src/sign_request.rs
+++ b/services/google/src/sign_request.rs
@@ -28,7 +28,7 @@ use std::time::Duration;
use reqsign_core::{
Context, Result, SignRequest, SigningCredential, SigningMethod, SigningRequest,
- hash::hex_sha256, jwt, time::*,
+ hash::hex_sha256, time::*,
};
use crate::constants::{DEFAULT_SCOPE, GOOG_QUERY_ENCODE_SET, GOOG_URI_ENCODE_SET, GOOGLE_SCOPE};
@@ -147,7 +147,7 @@ impl RequestSigner {
debug!("exchanging service account for token with scope: {scope}");
- let jwt = jwt::encode_rs256_pem(
+ let jwt = reqsign_jwt::encode_rs256_pem(
&JwtHeader::rs256(),
&Claims::new(&sa.client_email, &scope),
sa.private_key.as_bytes(),