This is an automated email from the ASF dual-hosted git repository. tison pushed a commit to branch bump-version in repository https://gitbox.apache.org/repos/asf/opendal-reqsign.git
commit 021b17a8153d2acf67142fbceaf59c994c29b9f8 Author: tison <[email protected]> AuthorDate: Wed Oct 1 22:57:31 2025 +0800 part 2 Signed-off-by: tison <[email protected]> --- Cargo.toml | 2 +- core/src/context.rs | 26 +++++----- core/src/hash.rs | 2 +- core/src/request.rs | 8 ++-- reqsign/src/aliyun.rs | 2 +- reqsign/src/aws.rs | 2 +- reqsign/src/azure.rs | 2 +- reqsign/src/google.rs | 2 +- reqsign/src/huaweicloud.rs | 2 +- reqsign/src/oracle.rs | 2 +- reqsign/src/tencent.rs | 2 +- rust-toolchain.toml | 2 +- services/aliyun-oss/Cargo.toml | 40 ++++++++-------- services/aliyun-oss/examples/oss_operations.rs | 4 +- services/aliyun-oss/src/credential.rs | 4 +- .../provide_credential/assume_role_with_oidc.rs | 4 +- .../aliyun-oss/src/provide_credential/default.rs | 2 +- services/aliyun-oss/src/provide_credential/env.rs | 2 +- services/aliyun-oss/src/sign_request.rs | 6 +-- services/aliyun-oss/tests/main.rs | 4 +- services/aws-v4/Cargo.toml | 56 +++++++++++----------- services/aws-v4/benches/aws.rs | 2 +- services/aws-v4/src/credential.rs | 4 +- .../aws-v4/src/provide_credential/assume_role.rs | 7 ++- .../assume_role_with_web_identity.rs | 8 ++-- services/aws-v4/src/provide_credential/default.rs | 2 +- services/aws-v4/src/provide_credential/env.rs | 2 +- services/aws-v4/src/provide_credential/imds.rs | 6 +-- services/aws-v4/src/provide_credential/profile.rs | 2 +- .../src/provide_credential/s3_express_session.rs | 2 +- services/aws-v4/src/provide_credential/sso.rs | 2 +- services/aws-v4/src/sign_request.rs | 12 ++--- services/aws-v4/tests/credential_providers/ecs.rs | 4 +- services/aws-v4/tests/signing/special_chars.rs | 2 +- services/azure-storage/Cargo.toml | 50 +++++++++---------- services/azure-storage/src/account_sas.rs | 5 +- services/azure-storage/src/credential.rs | 4 +- .../src/provide_credential/client_certificate.rs | 4 +- .../src/provide_credential/default.rs | 2 +- services/azure-storage/src/sign_request.rs | 45 ++++++++++------- services/google/Cargo.toml | 46 +++++++++--------- services/google/src/credential.rs | 2 +- .../src/provide_credential/authorized_user.rs | 2 +- .../src/provide_credential/external_account.rs | 4 +- .../impersonated_service_account.rs | 2 +- .../src/provide_credential/static_provider.rs | 2 +- .../google/src/provide_credential/vm_metadata.rs | 2 +- services/google/src/sign_request.rs | 6 +-- services/huaweicloud-obs/Cargo.toml | 34 ++++++------- services/huaweicloud-obs/src/credential.rs | 2 +- .../huaweicloud-obs/src/provide_credential/env.rs | 2 +- services/huaweicloud-obs/src/sign_request.rs | 8 ++-- services/oracle/Cargo.toml | 30 ++++++------ services/oracle/src/config.rs | 2 +- services/oracle/src/credential.rs | 4 +- .../oracle/src/provide_credential/config_file.rs | 2 +- services/oracle/src/provide_credential/default.rs | 2 +- services/oracle/src/provide_credential/env.rs | 2 +- services/oracle/src/sign_request.rs | 8 ++-- services/tencent-cos/Cargo.toml | 42 ++++++++-------- services/tencent-cos/src/credential.rs | 4 +- .../assume_role_with_web_identity.rs | 50 ++++++++++--------- .../tencent-cos/src/provide_credential/default.rs | 2 +- services/tencent-cos/src/provide_credential/env.rs | 2 +- services/tencent-cos/src/sign_request.rs | 9 ++-- services/tencent-cos/tests/main.rs | 6 +-- 66 files changed, 323 insertions(+), 295 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 2477b27..dceadf1 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -58,7 +58,7 @@ once_cell = "1" percent-encoding = "2" pretty_assertions = "1.3" quick-xml = { version = "0.38.1", features = ["serialize"] } -rand = { version = "0.9.2" } +rand = { version = "0.8.5" } reqwest = { version = "0.12", default-features = false } rsa = { version = "0.9.2", features = ["pkcs5", "sha2"] } rust-ini = { version = "0.21" } diff --git a/core/src/context.rs b/core/src/context.rs index beeca16..4ac3591 100644 --- a/core/src/context.rs +++ b/core/src/context.rs @@ -169,7 +169,7 @@ impl Context { self.env.var(key) } - /// Returns an hashmap of (variable, value) pairs of strings, for all the + /// Returns a hashmap of (variable, value) pairs of strings, for all the /// environment variables of the current process. #[inline] pub fn env_vars(&self) -> HashMap<String, String> { @@ -211,7 +211,7 @@ pub trait Env: Debug + Send + Sync + 'static { /// - Returns `None` if the environment variable is not found or value is invalid. fn var(&self, key: &str) -> Option<String>; - /// Returns an hashmap of (variable, value) pairs of strings, for all the + /// Returns a hashmap of (variable, value) pairs of strings, for all the /// environment variables of the current process. fn vars(&self) -> HashMap<String, String>; @@ -382,7 +382,7 @@ mod windows { use windows_sys::Win32::Foundation::S_OK; use windows_sys::Win32::System::Com::CoTaskMemFree; use windows_sys::Win32::UI::Shell::{ - FOLDERID_Profile, SHGetKnownFolderPath, KF_FLAG_DONT_VERIFY, + FOLDERID_Profile, KF_FLAG_DONT_VERIFY, SHGetKnownFolderPath, }; pub fn home_dir_inner() -> Option<PathBuf> { @@ -422,8 +422,8 @@ mod windows { None } - extern "C" { - fn wcslen(buf: *const u16) -> usize; + unsafe extern "C" { + unsafe fn wcslen(buf: *const u16) -> usize; } #[cfg(not(target_vendor = "uwp"))] @@ -437,18 +437,18 @@ mod windows { #[test] fn test_with_without() { let olduserprofile = env::var_os("USERPROFILE").unwrap(); - - env::remove_var("HOME"); - env::remove_var("USERPROFILE"); - + unsafe { + env::remove_var("HOME"); + env::remove_var("USERPROFILE"); + } assert_eq!(home_dir_inner(), Some(PathBuf::from(olduserprofile))); let home = Path::new(r"C:\Users\foo tar baz"); - - env::set_var("HOME", home.as_os_str()); + unsafe { + env::set_var("HOME", home.as_os_str()); + env::set_var("USERPROFILE", home.as_os_str()); + } assert_ne!(home_dir_inner().as_ref().map(Deref::deref), Some(home)); - - env::set_var("USERPROFILE", home.as_os_str()); assert_eq!(home_dir_inner().as_ref().map(Deref::deref), Some(home)); } } diff --git a/core/src/hash.rs b/core/src/hash.rs index 0976017..14dc1d4 100644 --- a/core/src/hash.rs +++ b/core/src/hash.rs @@ -18,8 +18,8 @@ //! Hash related utils. use crate::Error; -use base64::prelude::BASE64_STANDARD; use base64::Engine; +use base64::prelude::BASE64_STANDARD; use hmac::Hmac; use hmac::Mac; use sha1::Sha1; diff --git a/core/src/request.rs b/core/src/request.rs index d9881ed..2265cfe 100644 --- a/core/src/request.rs +++ b/core/src/request.rs @@ -20,14 +20,14 @@ use std::mem; use std::time::Duration; use crate::{Error, Result}; -use http::header::HeaderName; -use http::uri::Authority; -use http::uri::PathAndQuery; -use http::uri::Scheme; use http::HeaderMap; use http::HeaderValue; use http::Method; use http::Uri; +use http::header::HeaderName; +use http::uri::Authority; +use http::uri::PathAndQuery; +use http::uri::Scheme; use std::str::FromStr; /// Signing context for request. diff --git a/reqsign/src/aliyun.rs b/reqsign/src/aliyun.rs index 8fac61d..dc31190 100644 --- a/reqsign/src/aliyun.rs +++ b/reqsign/src/aliyun.rs @@ -24,7 +24,7 @@ pub use reqsign_aliyun_oss::*; #[cfg(feature = "default-context")] -use crate::{default_context, Signer}; +use crate::{Signer, default_context}; /// Default Aliyun OSS Signer type with commonly used components #[cfg(feature = "default-context")] diff --git a/reqsign/src/aws.rs b/reqsign/src/aws.rs index b52305c..113045f 100644 --- a/reqsign/src/aws.rs +++ b/reqsign/src/aws.rs @@ -24,7 +24,7 @@ pub use reqsign_aws_v4::*; #[cfg(feature = "default-context")] -use crate::{default_context, Signer}; +use crate::{Signer, default_context}; /// Default AWS Signer type with commonly used components #[cfg(feature = "default-context")] diff --git a/reqsign/src/azure.rs b/reqsign/src/azure.rs index 1df5962..1f4267f 100644 --- a/reqsign/src/azure.rs +++ b/reqsign/src/azure.rs @@ -24,7 +24,7 @@ pub use reqsign_azure_storage::*; #[cfg(feature = "default-context")] -use crate::{default_context, Signer}; +use crate::{Signer, default_context}; /// Default Azure Storage Signer type with commonly used components #[cfg(feature = "default-context")] diff --git a/reqsign/src/google.rs b/reqsign/src/google.rs index c38a8e2..4627a05 100644 --- a/reqsign/src/google.rs +++ b/reqsign/src/google.rs @@ -24,7 +24,7 @@ pub use reqsign_google::*; #[cfg(feature = "default-context")] -use crate::{default_context, Signer}; +use crate::{Signer, default_context}; /// Default Google Cloud Signer type with commonly used components #[cfg(feature = "default-context")] diff --git a/reqsign/src/huaweicloud.rs b/reqsign/src/huaweicloud.rs index d9373cb..e2bd380 100644 --- a/reqsign/src/huaweicloud.rs +++ b/reqsign/src/huaweicloud.rs @@ -24,7 +24,7 @@ pub use reqsign_huaweicloud_obs::*; #[cfg(feature = "default-context")] -use crate::{default_context, Signer}; +use crate::{Signer, default_context}; /// Default Huawei Cloud OBS Signer type with commonly used components #[cfg(feature = "default-context")] diff --git a/reqsign/src/oracle.rs b/reqsign/src/oracle.rs index a0ef0a1..8a6520c 100644 --- a/reqsign/src/oracle.rs +++ b/reqsign/src/oracle.rs @@ -24,7 +24,7 @@ pub use reqsign_oracle::*; #[cfg(feature = "default-context")] -use crate::{default_context, Signer}; +use crate::{Signer, default_context}; /// Default Oracle Cloud Signer type with commonly used components #[cfg(feature = "default-context")] diff --git a/reqsign/src/tencent.rs b/reqsign/src/tencent.rs index 722ff9b..11e3b5d 100644 --- a/reqsign/src/tencent.rs +++ b/reqsign/src/tencent.rs @@ -24,7 +24,7 @@ pub use reqsign_tencent_cos::*; #[cfg(feature = "default-context")] -use crate::{default_context, Signer}; +use crate::{Signer, default_context}; /// Default Tencent Cloud COS Signer type with commonly used components #[cfg(feature = "default-context")] diff --git a/rust-toolchain.toml b/rust-toolchain.toml index b1c6fbd..24ee9ce 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -16,5 +16,5 @@ # under the License. [toolchain] -channel = "1.85" +channel = "stable" components = ["cargo", "rustfmt", "clippy", "rust-analyzer"] diff --git a/services/aliyun-oss/Cargo.toml b/services/aliyun-oss/Cargo.toml index ea71e8f..880fc98 100644 --- a/services/aliyun-oss/Cargo.toml +++ b/services/aliyun-oss/Cargo.toml @@ -17,34 +17,34 @@ [package] name = "reqsign-aliyun-oss" -version = "1.0.0" +version = "1.1.0" + +description = "Aliyun OSS signing implementation for reqsign." -categories.workspace = true -description.workspace = true -documentation.workspace = true edition.workspace = true license.workspace = true repository.workspace = true +rust-version.workspace = true [dependencies] -anyhow.workspace = true -async-trait.workspace = true -http.workspace = true -jiff.workspace = true -log.workspace = true -once_cell.workspace = true -percent-encoding.workspace = true -reqsign-core.workspace = true +anyhow = { workspace = true } +async-trait = { workspace = true } +http = { workspace = true } +jiff = { workspace = true } +log = { workspace = true } +once_cell = { workspace = true } +percent-encoding = { workspace = true } +reqsign-core = { workspace = true } reqwest = { workspace = true, features = ["json"] } -serde.workspace = true -serde_json.workspace = true +serde = { workspace = true } +serde_json = { workspace = true } [dev-dependencies] -dotenv.workspace = true -env_logger.workspace = true -once_cell.workspace = true -reqsign-file-read-tokio.workspace = true -reqsign-http-send-reqwest.workspace = true +dotenv = { workspace = true } +env_logger = { workspace = true } +once_cell = { workspace = true } +reqsign-file-read-tokio = { workspace = true } +reqsign-http-send-reqwest = { workspace = true } reqwest = { workspace = true, features = ["rustls-tls"] } -temp-env.workspace = true +temp-env = { workspace = true } tokio = { workspace = true, features = ["full"] } diff --git a/services/aliyun-oss/examples/oss_operations.rs b/services/aliyun-oss/examples/oss_operations.rs index a0e6251..412cc91 100644 --- a/services/aliyun-oss/examples/oss_operations.rs +++ b/services/aliyun-oss/examples/oss_operations.rs @@ -49,7 +49,9 @@ async fn main() -> Result<()> { // Create the signer let signer = if demo_mode { println!("No Aliyun credentials found, using demo mode"); - println!("To use real credentials, set ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET"); + println!( + "To use real credentials, set ALIBABA_CLOUD_ACCESS_KEY_ID and ALIBABA_CLOUD_ACCESS_KEY_SECRET" + ); println!(); // Use demo credentials diff --git a/services/aliyun-oss/src/credential.rs b/services/aliyun-oss/src/credential.rs index 9ec61ed..2c66229 100644 --- a/services/aliyun-oss/src/credential.rs +++ b/services/aliyun-oss/src/credential.rs @@ -15,9 +15,9 @@ // specific language governing permissions and limitations // under the License. -use reqsign_core::time::{now, Timestamp}; -use reqsign_core::utils::Redact; use reqsign_core::SigningCredential; +use reqsign_core::time::{Timestamp, now}; +use reqsign_core::utils::Redact; use std::fmt::{Debug, Formatter}; /// Credential that holds the access_key and secret_key. diff --git a/services/aliyun-oss/src/provide_credential/assume_role_with_oidc.rs b/services/aliyun-oss/src/provide_credential/assume_role_with_oidc.rs index f30c751..e928d6d 100644 --- a/services/aliyun-oss/src/provide_credential/assume_role_with_oidc.rs +++ b/services/aliyun-oss/src/provide_credential/assume_role_with_oidc.rs @@ -15,10 +15,10 @@ // specific language governing permissions and limitations // under the License. -use crate::{constants::*, Credential}; +use crate::{Credential, constants::*}; use async_trait::async_trait; -use reqsign_core::time::{format_rfc3339, now, parse_rfc3339}; use reqsign_core::Result; +use reqsign_core::time::{format_rfc3339, now, parse_rfc3339}; use reqsign_core::{Context, ProvideCredential}; use serde::Deserialize; diff --git a/services/aliyun-oss/src/provide_credential/default.rs b/services/aliyun-oss/src/provide_credential/default.rs index d6f7190..dc32732 100644 --- a/services/aliyun-oss/src/provide_credential/default.rs +++ b/services/aliyun-oss/src/provide_credential/default.rs @@ -15,8 +15,8 @@ // specific language governing permissions and limitations // under the License. -use crate::provide_credential::{AssumeRoleWithOidcCredentialProvider, EnvCredentialProvider}; use crate::Credential; +use crate::provide_credential::{AssumeRoleWithOidcCredentialProvider, EnvCredentialProvider}; use async_trait::async_trait; use reqsign_core::{Context, ProvideCredential, ProvideCredentialChain, Result}; diff --git a/services/aliyun-oss/src/provide_credential/env.rs b/services/aliyun-oss/src/provide_credential/env.rs index b360802..56d700c 100644 --- a/services/aliyun-oss/src/provide_credential/env.rs +++ b/services/aliyun-oss/src/provide_credential/env.rs @@ -15,7 +15,7 @@ // specific language governing permissions and limitations // under the License. -use crate::{constants::*, Credential}; +use crate::{Credential, constants::*}; use async_trait::async_trait; use reqsign_core::{Context, ProvideCredential, Result}; diff --git a/services/aliyun-oss/src/sign_request.rs b/services/aliyun-oss/src/sign_request.rs index 08df07b..fe69a65 100644 --- a/services/aliyun-oss/src/sign_request.rs +++ b/services/aliyun-oss/src/sign_request.rs @@ -17,13 +17,13 @@ use crate::credential::Credential; use async_trait::async_trait; -use http::header::{AUTHORIZATION, CONTENT_TYPE, DATE}; use http::HeaderValue; +use http::header::{AUTHORIZATION, CONTENT_TYPE, DATE}; use once_cell::sync::Lazy; use percent_encoding::utf8_percent_encode; -use reqsign_core::hash::base64_hmac_sha1; -use reqsign_core::time::{format_http_date, now, Timestamp}; use reqsign_core::Result; +use reqsign_core::hash::base64_hmac_sha1; +use reqsign_core::time::{Timestamp, format_http_date, now}; use reqsign_core::{Context, SignRequest}; use std::collections::HashSet; use std::fmt::Write; diff --git a/services/aliyun-oss/tests/main.rs b/services/aliyun-oss/tests/main.rs index e0d3250..22e56f4 100644 --- a/services/aliyun-oss/tests/main.rs +++ b/services/aliyun-oss/tests/main.rs @@ -19,11 +19,11 @@ use std::env; use std::str::FromStr; use std::time::Duration; -use http::header::CONTENT_LENGTH; use http::Request; use http::StatusCode; +use http::header::CONTENT_LENGTH; use log::{debug, warn}; -use percent_encoding::{utf8_percent_encode, NON_ALPHANUMERIC}; +use percent_encoding::{NON_ALPHANUMERIC, utf8_percent_encode}; use reqsign_aliyun_oss::{RequestSigner, StaticCredentialProvider}; use reqsign_core::Result; use reqsign_core::{Context, OsEnv, Signer}; diff --git a/services/aws-v4/Cargo.toml b/services/aws-v4/Cargo.toml index 47acb30..97216d3 100644 --- a/services/aws-v4/Cargo.toml +++ b/services/aws-v4/Cargo.toml @@ -17,52 +17,52 @@ [package] name = "reqsign-aws-v4" -version = "1.0.0" +version = "1.1.0" + +description = "AWS SigV4 signing implementation for reqsign." -categories.workspace = true -description.workspace = true -documentation.workspace = true edition.workspace = true license.workspace = true repository.workspace = true +rust-version.workspace = true [[bench]] harness = false name = "aws" [dependencies] -anyhow.workspace = true -async-trait.workspace = true +anyhow = { workspace = true } +async-trait = { workspace = true } bytes = "1.7.2" -form_urlencoded.workspace = true -http.workspace = true -jiff.workspace = true -log.workspace = true -percent-encoding.workspace = true -quick-xml.workspace = true -reqsign-core.workspace = true -rust-ini.workspace = true -serde.workspace = true -serde_json.workspace = true +form_urlencoded = { workspace = true } +http = { workspace = true } +jiff = { workspace = true } +log = { workspace = true } +percent-encoding = { workspace = true } +quick-xml = { workspace = true } +reqsign-core = { workspace = true } +rust-ini = { workspace = true } +serde = { workspace = true } +serde_json = { workspace = true } serde_urlencoded = "0.7" sha1 = "0.10" [dev-dependencies] aws-credential-types = "1.1.8" aws-sigv4 = "1.2.0" -criterion.workspace = true -dotenv.workspace = true -env_logger.workspace = true -hex.workspace = true -macro_rules_attribute.workspace = true -once_cell.workspace = true -pretty_assertions.workspace = true -reqsign-http-send-reqwest.workspace = true +criterion = { workspace = true } +dotenv = { workspace = true } +env_logger = { workspace = true } +hex = { workspace = true } +macro_rules_attribute = { workspace = true } +once_cell = { workspace = true } +pretty_assertions = { workspace = true } +reqsign-http-send-reqwest = { workspace = true } reqwest = { workspace = true, features = ["rustls-tls"] } -sha2.workspace = true -temp-env.workspace = true -tempfile.workspace = true -test-case.workspace = true +sha2 = { workspace = true } +temp-env = { workspace = true } +tempfile = { workspace = true } +test-case = { workspace = true } tokio = { workspace = true, features = ["full"] } [target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies] diff --git a/services/aws-v4/benches/aws.rs b/services/aws-v4/benches/aws.rs index 6b70135..c74add0 100644 --- a/services/aws-v4/benches/aws.rs +++ b/services/aws-v4/benches/aws.rs @@ -23,9 +23,9 @@ use aws_sigv4::http_request::SignableBody; use aws_sigv4::http_request::SignableRequest; use aws_sigv4::http_request::SigningSettings; use aws_sigv4::sign::v4::SigningParams; +use criterion::Criterion; use criterion::criterion_group; use criterion::criterion_main; -use criterion::Criterion; use once_cell::sync::Lazy; use reqsign_aws_v4::Credential as AwsCredential; use reqsign_aws_v4::RequestSigner as AwsV4RequestSigner; diff --git a/services/aws-v4/src/credential.rs b/services/aws-v4/src/credential.rs index a0a1dbb..edb3806 100644 --- a/services/aws-v4/src/credential.rs +++ b/services/aws-v4/src/credential.rs @@ -15,9 +15,9 @@ // specific language governing permissions and limitations // under the License. -use reqsign_core::time::{now, Timestamp}; -use reqsign_core::utils::Redact; use reqsign_core::SigningCredential; +use reqsign_core::time::{Timestamp, now}; +use reqsign_core::utils::Redact; use std::fmt::{Debug, Formatter}; /// Credential that holds the access_key and secret_key. diff --git a/services/aws-v4/src/provide_credential/assume_role.rs b/services/aws-v4/src/provide_credential/assume_role.rs index e5ba258..a738a9b 100644 --- a/services/aws-v4/src/provide_credential/assume_role.rs +++ b/services/aws-v4/src/provide_credential/assume_role.rs @@ -15,10 +15,10 @@ // specific language governing permissions and limitations // under the License. +use crate::EMPTY_STRING_SHA256; use crate::constants::X_AMZ_CONTENT_SHA_256; use crate::credential::Credential; use crate::provide_credential::utils::{parse_sts_error, sts_endpoint}; -use crate::EMPTY_STRING_SHA256; use async_trait::async_trait; use bytes::Bytes; use quick_xml::de; @@ -148,7 +148,10 @@ impl ProvideCredential for AssumeRoleCredentialProvider { .map_err(|e| e.with_context(format!("role_arn: {}", self.role_arn)))?; // Construct request to AWS STS Service. - let mut url = format!("https://{endpoint}/?Action=AssumeRole&RoleArn={}&Version=2011-06-15&RoleSessionName={}", self.role_arn, self.role_session_name); + let mut url = format!( + "https://{endpoint}/?Action=AssumeRole&RoleArn={}&Version=2011-06-15&RoleSessionName={}", + self.role_arn, self.role_session_name + ); if let Some(external_id) = &self.external_id { write!(url, "&ExternalId={external_id}") .map_err(|e| Error::unexpected("failed to format URL").with_source(e))?; diff --git a/services/aws-v4/src/provide_credential/assume_role_with_web_identity.rs b/services/aws-v4/src/provide_credential/assume_role_with_web_identity.rs index 7c055d3..87c9933 100644 --- a/services/aws-v4/src/provide_credential/assume_role_with_web_identity.rs +++ b/services/aws-v4/src/provide_credential/assume_role_with_web_identity.rs @@ -15,13 +15,13 @@ // specific language governing permissions and limitations // under the License. -use crate::provide_credential::utils::{parse_sts_error, sts_endpoint}; use crate::Credential; +use crate::provide_credential::utils::{parse_sts_error, sts_endpoint}; use async_trait::async_trait; use bytes::Bytes; use quick_xml::de; use reqsign_core::time::parse_rfc3339; -use reqsign_core::{utils::Redact, Context, Error, ProvideCredential, Result}; +use reqsign_core::{Context, Error, ProvideCredential, Result, utils::Redact}; use serde::Deserialize; use std::fmt::{Debug, Formatter}; use std::path::PathBuf; @@ -151,7 +151,9 @@ impl ProvideCredential for AssumeRoleWithWebIdentityCredentialProvider { .unwrap_or_else(|| "reqsign".to_string()); // Construct request to AWS STS Service. - let url = format!("https://{endpoint}/?Action=AssumeRoleWithWebIdentity&RoleArn={role_arn}&WebIdentityToken={token}&Version=2011-06-15&RoleSessionName={session_name}"); + let url = format!( + "https://{endpoint}/?Action=AssumeRoleWithWebIdentity&RoleArn={role_arn}&WebIdentityToken={token}&Version=2011-06-15&RoleSessionName={session_name}" + ); let req = http::request::Request::builder() .method("GET") .uri(url) diff --git a/services/aws-v4/src/provide_credential/default.rs b/services/aws-v4/src/provide_credential/default.rs index 0b388f4..ca3cc46 100644 --- a/services/aws-v4/src/provide_credential/default.rs +++ b/services/aws-v4/src/provide_credential/default.rs @@ -15,13 +15,13 @@ // specific language governing permissions and limitations // under the License. +use crate::Credential; use crate::provide_credential::{ AssumeRoleWithWebIdentityCredentialProvider, ECSCredentialProvider, EnvCredentialProvider, IMDSv2CredentialProvider, ProfileCredentialProvider, }; #[cfg(not(target_arch = "wasm32"))] use crate::provide_credential::{ProcessCredentialProvider, SSOCredentialProvider}; -use crate::Credential; use async_trait::async_trait; use reqsign_core::{Context, ProvideCredential, ProvideCredentialChain, Result}; diff --git a/services/aws-v4/src/provide_credential/env.rs b/services/aws-v4/src/provide_credential/env.rs index 0256b3c..daa8fb3 100644 --- a/services/aws-v4/src/provide_credential/env.rs +++ b/services/aws-v4/src/provide_credential/env.rs @@ -15,7 +15,7 @@ // specific language governing permissions and limitations // under the License. -use crate::{constants::*, Credential}; +use crate::{Credential, constants::*}; use async_trait::async_trait; use reqsign_core::{Context, ProvideCredential, Result}; diff --git a/services/aws-v4/src/provide_credential/imds.rs b/services/aws-v4/src/provide_credential/imds.rs index a25af58..01eedc9 100644 --- a/services/aws-v4/src/provide_credential/imds.rs +++ b/services/aws-v4/src/provide_credential/imds.rs @@ -15,13 +15,13 @@ // specific language governing permissions and limitations // under the License. -use crate::provide_credential::utils::parse_imds_error; use crate::Credential; +use crate::provide_credential::utils::parse_imds_error; use async_trait::async_trait; use bytes::Bytes; -use http::header::CONTENT_LENGTH; use http::Method; -use reqsign_core::time::{now, parse_rfc3339, Timestamp}; +use http::header::CONTENT_LENGTH; +use reqsign_core::time::{Timestamp, now, parse_rfc3339}; use reqsign_core::{Context, Error, ProvideCredential, Result}; use serde::Deserialize; use std::sync::{Arc, Mutex}; diff --git a/services/aws-v4/src/provide_credential/profile.rs b/services/aws-v4/src/provide_credential/profile.rs index 7d9d6ae..09806d7 100644 --- a/services/aws-v4/src/provide_credential/profile.rs +++ b/services/aws-v4/src/provide_credential/profile.rs @@ -15,9 +15,9 @@ // specific language governing permissions and limitations // under the License. +use crate::Credential; #[cfg(not(target_arch = "wasm32"))] use crate::constants::*; -use crate::Credential; use async_trait::async_trait; #[cfg(not(target_arch = "wasm32"))] use ini::Ini; diff --git a/services/aws-v4/src/provide_credential/s3_express_session.rs b/services/aws-v4/src/provide_credential/s3_express_session.rs index 723b2bb..c1c5e79 100644 --- a/services/aws-v4/src/provide_credential/s3_express_session.rs +++ b/services/aws-v4/src/provide_credential/s3_express_session.rs @@ -18,7 +18,7 @@ use crate::Credential; use async_trait::async_trait; use bytes::Bytes; -use http::{header, Method, Request}; +use http::{Method, Request, header}; use log::debug; use reqsign_core::time::parse_rfc3339; use reqsign_core::{Context, Error, ProvideCredential, Result, SignRequest}; diff --git a/services/aws-v4/src/provide_credential/sso.rs b/services/aws-v4/src/provide_credential/sso.rs index a0adaec..04f9ece 100644 --- a/services/aws-v4/src/provide_credential/sso.rs +++ b/services/aws-v4/src/provide_credential/sso.rs @@ -20,7 +20,7 @@ use async_trait::async_trait; use http::{Method, Request, StatusCode}; use ini::Ini; use log::{debug, warn}; -use reqsign_core::time::{now, Timestamp}; +use reqsign_core::time::{Timestamp, now}; use reqsign_core::{Context, Error, ProvideCredential, Result}; use serde::Deserialize; diff --git a/services/aws-v4/src/sign_request.rs b/services/aws-v4/src/sign_request.rs index 6b27ddf..7516ea4 100644 --- a/services/aws-v4/src/sign_request.rs +++ b/services/aws-v4/src/sign_request.rs @@ -15,18 +15,18 @@ // specific language governing permissions and limitations // under the License. +use crate::Credential; use crate::constants::{ AWS_QUERY_ENCODE_SET, X_AMZ_CONTENT_SHA_256, X_AMZ_DATE, X_AMZ_S3_SESSION_TOKEN, X_AMZ_SECURITY_TOKEN, }; -use crate::Credential; use async_trait::async_trait; use http::request::Parts; -use http::{header, HeaderValue}; +use http::{HeaderValue, header}; use log::debug; use percent_encoding::{percent_decode_str, utf8_percent_encode}; use reqsign_core::hash::{hex_hmac_sha256, hex_sha256, hmac_sha256}; -use reqsign_core::time::{format_date, format_iso8601, now, Timestamp}; +use reqsign_core::time::{Timestamp, format_date, format_iso8601, now}; use reqsign_core::{Context, Result, SignRequest, SigningRequest}; use std::fmt::Write; use std::time::Duration; @@ -361,9 +361,9 @@ fn generate_signing_key(secret: &str, time: Timestamp, region: &str, service: &s // Sign service let sign_service = hmac_sha256(sign_region.as_slice(), service.as_bytes()); // Sign request - let sign_request = hmac_sha256(sign_service.as_slice(), "aws4_request".as_bytes()); + - sign_request + hmac_sha256(sign_service.as_slice(), "aws4_request".as_bytes()) } #[cfg(test)] @@ -381,8 +381,8 @@ mod tests { use aws_sigv4::http_request::SignatureLocation; use aws_sigv4::http_request::SigningSettings; use aws_sigv4::sign::v4; - use http::header; use http::Request; + use http::header; use reqsign_core::ProvideCredential; use reqsign_file_read_tokio::TokioFileRead; use reqsign_http_send_reqwest::ReqwestHttpSend; diff --git a/services/aws-v4/tests/credential_providers/ecs.rs b/services/aws-v4/tests/credential_providers/ecs.rs index d9b19c0..6b555d8 100644 --- a/services/aws-v4/tests/credential_providers/ecs.rs +++ b/services/aws-v4/tests/credential_providers/ecs.rs @@ -49,7 +49,9 @@ async fn test_ecs_credential_provider() { envs.insert("AWS_CONTAINER_AUTHORIZATION_TOKEN".to_string(), token); } } else { - panic!("Either AWS_CONTAINER_CREDENTIALS_RELATIVE_URI or AWS_CONTAINER_CREDENTIALS_FULL_URI must be set"); + panic!( + "Either AWS_CONTAINER_CREDENTIALS_RELATIVE_URI or AWS_CONTAINER_CREDENTIALS_FULL_URI must be set" + ); } let ctx = create_test_context_with_env(envs); diff --git a/services/aws-v4/tests/signing/special_chars.rs b/services/aws-v4/tests/signing/special_chars.rs index f1204bf..5ae3b24 100644 --- a/services/aws-v4/tests/signing/special_chars.rs +++ b/services/aws-v4/tests/signing/special_chars.rs @@ -19,7 +19,7 @@ use super::{init_signing_test, load_static_credential, send_signed_request}; use anyhow::Result; use http::{Method, Request, StatusCode}; use log::warn; -use percent_encoding::{utf8_percent_encode, NON_ALPHANUMERIC}; +use percent_encoding::{NON_ALPHANUMERIC, utf8_percent_encode}; use std::str::FromStr; #[tokio::test] diff --git a/services/azure-storage/Cargo.toml b/services/azure-storage/Cargo.toml index ca3cfe7..3c0acad 100644 --- a/services/azure-storage/Cargo.toml +++ b/services/azure-storage/Cargo.toml @@ -17,42 +17,42 @@ [package] name = "reqsign-azure-storage" -version = "1.0.0" +version = "1.1.0" + +description = "Azure Storage signing implementation for reqsign." -categories.workspace = true -description.workspace = true -documentation.workspace = true edition.workspace = true license.workspace = true repository.workspace = true +rust-version.workspace = true [dependencies] -anyhow.workspace = true -async-trait.workspace = true -base64.workspace = true -bytes.workspace = true -form_urlencoded.workspace = true -http.workspace = true -jiff.workspace = true -log.workspace = true -percent-encoding.workspace = true -reqsign-core.workspace = true -serde.workspace = true -serde_json.workspace = true -sha1.workspace = true -sha2.workspace = true +anyhow = { workspace = true } +async-trait = { workspace = true } +base64 = { workspace = true } +bytes = { workspace = true } +form_urlencoded = { workspace = true } +http = { workspace = true } +jiff = { workspace = true } +log = { workspace = true } +percent-encoding = { workspace = true } +reqsign-core = { workspace = true } +serde = { workspace = true } +serde_json = { workspace = true } +sha1 = { workspace = true } +sha2 = { workspace = true } [target.'cfg(not(target_arch = "wasm32"))'.dependencies] jsonwebtoken = "9.2" pem = "3.0" -rsa.workspace = true +rsa = { workspace = true } [dev-dependencies] -async-trait.workspace = true -dotenv.workspace = true -env_logger.workspace = true -reqsign-command-execute-tokio.workspace = true -reqsign-file-read-tokio.workspace = true -reqsign-http-send-reqwest.workspace = true +async-trait = { workspace = true } +dotenv = { workspace = true } +env_logger = { workspace = true } +reqsign-command-execute-tokio = { workspace = true } +reqsign-file-read-tokio = { workspace = true } +reqsign-http-send-reqwest = { workspace = true } reqwest = { workspace = true, features = ["rustls-tls"] } tokio = { workspace = true, features = ["full"] } diff --git a/services/azure-storage/src/account_sas.rs b/services/azure-storage/src/account_sas.rs index 7eff18a..e7c79fc 100644 --- a/services/azure-storage/src/account_sas.rs +++ b/services/azure-storage/src/account_sas.rs @@ -141,6 +141,9 @@ mod tests { .collect::<Vec<String>>() .join("&"); - assert_eq!(token, "sv=2018-11-09&ss=bqtf&srt=sco&se=2022-03-01T08%3A17%3A34Z&sp=rwdlacu&sig=jgK9nDUT0ntH%2Fp28LPs0jzwxsk91W6hePLPlfrElv4k%3D"); + assert_eq!( + token, + "sv=2018-11-09&ss=bqtf&srt=sco&se=2022-03-01T08%3A17%3A34Z&sp=rwdlacu&sig=jgK9nDUT0ntH%2Fp28LPs0jzwxsk91W6hePLPlfrElv4k%3D" + ); } } diff --git a/services/azure-storage/src/credential.rs b/services/azure-storage/src/credential.rs index e824bc9..faaa4c4 100644 --- a/services/azure-storage/src/credential.rs +++ b/services/azure-storage/src/credential.rs @@ -15,9 +15,9 @@ // specific language governing permissions and limitations // under the License. -use reqsign_core::time::{now, Timestamp}; -use reqsign_core::utils::Redact; use reqsign_core::SigningCredential; +use reqsign_core::time::{Timestamp, now}; +use reqsign_core::utils::Redact; use std::fmt::{Debug, Formatter}; /// Credential enum for different Azure Storage authentication methods. diff --git a/services/azure-storage/src/provide_credential/client_certificate.rs b/services/azure-storage/src/provide_credential/client_certificate.rs index 7268568..97bff76 100644 --- a/services/azure-storage/src/provide_credential/client_certificate.rs +++ b/services/azure-storage/src/provide_credential/client_certificate.rs @@ -20,13 +20,13 @@ use std::time::{Duration, SystemTime, UNIX_EPOCH}; use crate::credential::Credential; use async_trait::async_trait; -use base64::engine::general_purpose::URL_SAFE_NO_PAD; use base64::Engine; +use base64::engine::general_purpose::URL_SAFE_NO_PAD; use jsonwebtoken::{Algorithm, EncodingKey, Header}; use reqsign_core::time::now; use reqsign_core::{Context, ProvideCredential}; -use rsa::pkcs8::DecodePrivateKey; use rsa::RsaPrivateKey; +use rsa::pkcs8::DecodePrivateKey; use serde::{Deserialize, Serialize}; use sha1::{Digest, Sha1}; diff --git a/services/azure-storage/src/provide_credential/default.rs b/services/azure-storage/src/provide_credential/default.rs index 02ab0a9..0e698fa 100644 --- a/services/azure-storage/src/provide_credential/default.rs +++ b/services/azure-storage/src/provide_credential/default.rs @@ -15,13 +15,13 @@ // specific language governing permissions and limitations // under the License. +use crate::Credential; #[cfg(not(target_arch = "wasm32"))] use crate::provide_credential::{AzureCliCredentialProvider, ClientCertificateCredentialProvider}; use crate::provide_credential::{ AzurePipelinesCredentialProvider, ClientSecretCredentialProvider, EnvCredentialProvider, ImdsCredentialProvider, WorkloadIdentityCredentialProvider, }; -use crate::Credential; use async_trait::async_trait; use reqsign_core::{Context, ProvideCredential, ProvideCredentialChain, Result}; diff --git a/services/azure-storage/src/sign_request.rs b/services/azure-storage/src/sign_request.rs index c528a07..aceb460 100644 --- a/services/azure-storage/src/sign_request.rs +++ b/services/azure-storage/src/sign_request.rs @@ -15,15 +15,15 @@ // specific language governing permissions and limitations // under the License. -use crate::constants::*; use crate::Credential; +use crate::constants::*; use async_trait::async_trait; use http::request::Parts; -use http::{header, HeaderValue}; +use http::{HeaderValue, header}; use log::debug; use percent_encoding::percent_encode; use reqsign_core::hash::{base64_decode, base64_hmac_sha256}; -use reqsign_core::time::{format_http_date, now, Timestamp}; +use reqsign_core::time::{Timestamp, format_http_date, now}; use reqsign_core::{Context, Result, SignRequest, SigningMethod, SigningRequest}; use std::fmt::Write; use std::time::Duration; @@ -428,7 +428,9 @@ mod tests { .with_file_read(TokioFileRead) .with_http_send(ReqwestHttpSend::default()) .with_env(OsEnv); - let cred = Credential::with_sas_token("sv=2021-01-01&ss=b&srt=c&sp=rwdlaciytfx&se=2022-01-01T11:00:14Z&st=2022-01-02T03:00:14Z&spr=https&sig=KEllk4N8f7rJfLjQCmikL2fRVt%2B%2Bl73UBkbgH%2FK3VGE%3D"); + let cred = Credential::with_sas_token( + "sv=2021-01-01&ss=b&srt=c&sp=rwdlaciytfx&se=2022-01-01T11:00:14Z&st=2022-01-02T03:00:14Z&spr=https&sig=KEllk4N8f7rJfLjQCmikL2fRVt%2B%2Bl73UBkbgH%2FK3VGE%3D", + ); let builder = RequestSigner::new(); @@ -440,11 +442,16 @@ mod tests { let (mut parts, _) = req.into_parts(); // Test query signing - assert!(builder - .sign_request(&ctx, &mut parts, Some(&cred), Some(Duration::from_secs(1))) - .await - .is_ok()); - assert_eq!(parts.uri, "https://test.blob.core.windows.net/testbucket/testblob?sv=2021-01-01&ss=b&srt=c&sp=rwdlaciytfx&se=2022-01-01T11:00:14Z&st=2022-01-02T03:00:14Z&spr=https&sig=KEllk4N8f7rJfLjQCmikL2fRVt%2B%2Bl73UBkbgH%2FK3VGE%3D") + assert!( + builder + .sign_request(&ctx, &mut parts, Some(&cred), Some(Duration::from_secs(1))) + .await + .is_ok() + ); + assert_eq!( + parts.uri, + "https://test.blob.core.windows.net/testbucket/testblob?sv=2021-01-01&ss=b&srt=c&sp=rwdlaciytfx&se=2022-01-01T11:00:14Z&st=2022-01-02T03:00:14Z&spr=https&sig=KEllk4N8f7rJfLjQCmikL2fRVt%2B%2Bl73UBkbgH%2FK3VGE%3D" + ) } #[tokio::test] @@ -466,10 +473,12 @@ mod tests { let (mut parts, _) = req.into_parts(); // Can effectively sign request with header method - assert!(builder - .sign_request(&ctx, &mut parts, Some(&cred), None) - .await - .is_ok()); + assert!( + builder + .sign_request(&ctx, &mut parts, Some(&cred), None) + .await + .is_ok() + ); let authorization = parts .headers .get("Authorization") @@ -484,9 +493,11 @@ mod tests { .body(()) .unwrap(); let (mut parts, _) = req.into_parts(); - assert!(builder - .sign_request(&ctx, &mut parts, Some(&cred), Some(Duration::from_secs(1))) - .await - .is_err()); + assert!( + builder + .sign_request(&ctx, &mut parts, Some(&cred), Some(Duration::from_secs(1))) + .await + .is_err() + ); } } diff --git a/services/google/Cargo.toml b/services/google/Cargo.toml index 58d3864..05c56f6 100644 --- a/services/google/Cargo.toml +++ b/services/google/Cargo.toml @@ -17,37 +17,37 @@ [package] name = "reqsign-google" -version = "1.0.0" +version = "1.1.0" + +description = "Goole Cloud Platform signing implementation for reqsign." -categories.workspace = true -description.workspace = true -documentation.workspace = true edition.workspace = true license.workspace = true repository.workspace = true +rust-version.workspace = true [dependencies] -async-trait.workspace = true -http.workspace = true -jiff.workspace = true +async-trait = { workspace = true } +http = { workspace = true } +jiff = { workspace = true } jsonwebtoken = "9.2" -log.workspace = true -percent-encoding.workspace = true -rand.workspace = true -reqsign-core.workspace = true -reqwest.workspace = true -rsa.workspace = true -serde.workspace = true -serde_json.workspace = true -sha2.workspace = true +log = { workspace = true } +percent-encoding = { workspace = true } +rand = { workspace = true } +reqsign-core = { workspace = true } +reqwest = { workspace = true } +rsa = { workspace = true } +serde = { workspace = true } +serde_json = { workspace = true } +sha2 = { workspace = true } [dev-dependencies] -dotenv.workspace = true -env_logger.workspace = true -pretty_assertions.workspace = true -reqsign-file-read-tokio.workspace = true -reqsign-http-send-reqwest.workspace = true +dotenv = { workspace = true } +env_logger = { workspace = true } +pretty_assertions = { workspace = true } +reqsign-file-read-tokio = { workspace = true } +reqsign-http-send-reqwest = { workspace = true } reqwest = { workspace = true, features = ["rustls-tls"] } -sha2.workspace = true -temp-env.workspace = true +sha2 = { workspace = true } +temp-env = { workspace = true } tokio = { workspace = true, features = ["full"] } diff --git a/services/google/src/credential.rs b/services/google/src/credential.rs index ace9f94..700ead0 100644 --- a/services/google/src/credential.rs +++ b/services/google/src/credential.rs @@ -16,7 +16,7 @@ // under the License. use reqsign_core::{ - time::now, time::Timestamp, utils::Redact, Result, SigningCredential as KeyTrait, + Result, SigningCredential as KeyTrait, time::Timestamp, time::now, utils::Redact, }; use std::fmt::{self, Debug}; diff --git a/services/google/src/provide_credential/authorized_user.rs b/services/google/src/provide_credential/authorized_user.rs index e510e5e..f805175 100644 --- a/services/google/src/provide_credential/authorized_user.rs +++ b/services/google/src/provide_credential/authorized_user.rs @@ -19,7 +19,7 @@ use http::header::CONTENT_TYPE; use log::{debug, error}; use serde::{Deserialize, Serialize}; -use reqsign_core::{time::now, Context, ProvideCredential, Result}; +use reqsign_core::{Context, ProvideCredential, Result, time::now}; use crate::credential::{Credential, OAuth2Credentials, Token}; diff --git a/services/google/src/provide_credential/external_account.rs b/services/google/src/provide_credential/external_account.rs index 4cd7c2a..a4dba76 100644 --- a/services/google/src/provide_credential/external_account.rs +++ b/services/google/src/provide_credential/external_account.rs @@ -21,9 +21,9 @@ use http::header::{ACCEPT, CONTENT_TYPE}; use log::{debug, error}; use serde::{Deserialize, Serialize}; -use crate::credential::{external_account, Credential, ExternalAccount, Token}; +use crate::credential::{Credential, ExternalAccount, Token, external_account}; use reqsign_core::time::parse_rfc3339; -use reqsign_core::{time::now, Context, ProvideCredential, Result}; +use reqsign_core::{Context, ProvideCredential, Result, time::now}; /// The maximum impersonated token lifetime allowed, 1 hour. const MAX_LIFETIME: Duration = Duration::from_secs(3600); diff --git a/services/google/src/provide_credential/impersonated_service_account.rs b/services/google/src/provide_credential/impersonated_service_account.rs index 5760488..6035a6f 100644 --- a/services/google/src/provide_credential/impersonated_service_account.rs +++ b/services/google/src/provide_credential/impersonated_service_account.rs @@ -23,7 +23,7 @@ use serde::{Deserialize, Serialize}; use crate::credential::{Credential, ImpersonatedServiceAccount, Token}; use reqsign_core::time::parse_rfc3339; -use reqsign_core::{time::now, Context, ProvideCredential, Result}; +use reqsign_core::{Context, ProvideCredential, Result, time::now}; /// The maximum impersonated token lifetime allowed, 1 hour. const MAX_LIFETIME: Duration = Duration::from_secs(3600); diff --git a/services/google/src/provide_credential/static_provider.rs b/services/google/src/provide_credential/static_provider.rs index 73bb2df..b893bda 100644 --- a/services/google/src/provide_credential/static_provider.rs +++ b/services/google/src/provide_credential/static_provider.rs @@ -17,7 +17,7 @@ use log::debug; -use reqsign_core::{hash::base64_decode, Context, ProvideCredential, Result}; +use reqsign_core::{Context, ProvideCredential, Result, hash::base64_decode}; use crate::credential::{Credential, CredentialFile}; diff --git a/services/google/src/provide_credential/vm_metadata.rs b/services/google/src/provide_credential/vm_metadata.rs index 48b2421..abf8839 100644 --- a/services/google/src/provide_credential/vm_metadata.rs +++ b/services/google/src/provide_credential/vm_metadata.rs @@ -18,7 +18,7 @@ use log::debug; use serde::Deserialize; -use reqsign_core::{time::now, Context, ProvideCredential, Result}; +use reqsign_core::{Context, ProvideCredential, Result, time::now}; use crate::credential::{Credential, Token}; diff --git a/services/google/src/sign_request.rs b/services/google/src/sign_request.rs index b2d58a4..e7aa3f7 100644 --- a/services/google/src/sign_request.rs +++ b/services/google/src/sign_request.rs @@ -28,11 +28,11 @@ use std::borrow::Cow; use std::time::Duration; use reqsign_core::{ - hash::hex_sha256, time::*, Context, Result, SignRequest, SigningCredential, SigningMethod, - SigningRequest, + Context, Result, SignRequest, SigningCredential, SigningMethod, SigningRequest, + hash::hex_sha256, time::*, }; -use crate::constants::{DEFAULT_SCOPE, GOOGLE_SCOPE, GOOG_QUERY_ENCODE_SET, GOOG_URI_ENCODE_SET}; +use crate::constants::{DEFAULT_SCOPE, GOOG_QUERY_ENCODE_SET, GOOG_URI_ENCODE_SET, GOOGLE_SCOPE}; use crate::credential::{Credential, ServiceAccount, Token}; /// Claims is used to build JWT for Google Cloud. diff --git a/services/huaweicloud-obs/Cargo.toml b/services/huaweicloud-obs/Cargo.toml index 3f0c464..923ee10 100644 --- a/services/huaweicloud-obs/Cargo.toml +++ b/services/huaweicloud-obs/Cargo.toml @@ -17,29 +17,29 @@ [package] name = "reqsign-huaweicloud-obs" -version = "1.0.0" +version = "1.1.0" + +description = "Huawei Cloud OBS signing implementation for reqsign." -categories.workspace = true -description.workspace = true -documentation.workspace = true edition.workspace = true license.workspace = true repository.workspace = true +rust-version.workspace = true [dependencies] -anyhow.workspace = true -async-trait.workspace = true -http.workspace = true -jiff.workspace = true -log.workspace = true -once_cell.workspace = true -percent-encoding.workspace = true -reqsign-core.workspace = true +anyhow = { workspace = true } +async-trait = { workspace = true } +http = { workspace = true } +jiff = { workspace = true } +log = { workspace = true } +once_cell = { workspace = true } +percent-encoding = { workspace = true } +reqsign-core = { workspace = true } [dev-dependencies] -env_logger.workspace = true -once_cell.workspace = true -reqsign-file-read-tokio.workspace = true -reqsign-http-send-reqwest.workspace = true -temp-env.workspace = true +env_logger = { workspace = true } +once_cell = { workspace = true } +reqsign-file-read-tokio = { workspace = true } +reqsign-http-send-reqwest = { workspace = true } +temp-env = { workspace = true } tokio = { workspace = true, features = ["full"] } diff --git a/services/huaweicloud-obs/src/credential.rs b/services/huaweicloud-obs/src/credential.rs index 0ae76a1..19999a3 100644 --- a/services/huaweicloud-obs/src/credential.rs +++ b/services/huaweicloud-obs/src/credential.rs @@ -17,7 +17,7 @@ use std::fmt::{Debug, Formatter}; -use reqsign_core::{utils::Redact, SigningCredential}; +use reqsign_core::{SigningCredential, utils::Redact}; /// Credential for obs. #[derive(Clone)] diff --git a/services/huaweicloud-obs/src/provide_credential/env.rs b/services/huaweicloud-obs/src/provide_credential/env.rs index 38616f8..8d4c555 100644 --- a/services/huaweicloud-obs/src/provide_credential/env.rs +++ b/services/huaweicloud-obs/src/provide_credential/env.rs @@ -15,7 +15,7 @@ // specific language governing permissions and limitations // under the License. -use crate::{constants::*, Credential}; +use crate::{Credential, constants::*}; use async_trait::async_trait; use reqsign_core::{Context, ProvideCredential, Result}; diff --git a/services/huaweicloud-obs/src/sign_request.rs b/services/huaweicloud-obs/src/sign_request.rs index 893c0a1..27c40ca 100644 --- a/services/huaweicloud-obs/src/sign_request.rs +++ b/services/huaweicloud-obs/src/sign_request.rs @@ -20,10 +20,10 @@ use std::collections::HashSet; use std::fmt::Write; use std::time::Duration; +use http::HeaderValue; use http::header::AUTHORIZATION; use http::header::CONTENT_TYPE; use http::header::DATE; -use http::HeaderValue; use log::debug; use once_cell::sync::Lazy; use percent_encoding::utf8_percent_encode; @@ -32,9 +32,9 @@ use reqsign_core::Result; use super::constants::*; use super::credential::Credential; use reqsign_core::hash::base64_hmac_sha1; +use reqsign_core::time::Timestamp; use reqsign_core::time::format_http_date; use reqsign_core::time::now; -use reqsign_core::time::Timestamp; use reqsign_core::{SignRequest, SigningMethod, SigningRequest}; /// RequestSigner that implement Huawei Cloud Object Storage Service Authorization. @@ -303,10 +303,10 @@ static SUBRESOURCES: Lazy<HashSet<&'static str>> = Lazy::new(|| { mod tests { use std::str::FromStr; - use http::header::HeaderName; use http::Uri; - use reqsign_core::time::parse_rfc2822; + use http::header::HeaderName; use reqsign_core::Result; + use reqsign_core::time::parse_rfc2822; use reqsign_core::{Context, OsEnv, Signer}; use reqsign_file_read_tokio::TokioFileRead; use reqsign_http_send_reqwest::ReqwestHttpSend; diff --git a/services/oracle/Cargo.toml b/services/oracle/Cargo.toml index 8531cea..1e258f6 100644 --- a/services/oracle/Cargo.toml +++ b/services/oracle/Cargo.toml @@ -17,28 +17,28 @@ [package] name = "reqsign-oracle" -version = "1.0.0" +version = "1.1.0" + +description = "Oracle Cloud signing implementation for reqsign." -categories.workspace = true -description.workspace = true -documentation.workspace = true edition.workspace = true license.workspace = true repository.workspace = true +rust-version.workspace = true [dependencies] -anyhow.workspace = true -async-trait.workspace = true -base64.workspace = true -http.workspace = true -jiff.workspace = true -log.workspace = true -reqsign-core.workspace = true -rsa.workspace = true -rust-ini.workspace = true +anyhow = { workspace = true } +async-trait = { workspace = true } +base64 = { workspace = true } +http = { workspace = true } +jiff = { workspace = true } +log = { workspace = true } +reqsign-core = { workspace = true } +rsa = { workspace = true } +rust-ini = { workspace = true } [dev-dependencies] env_logger = "0.11" -reqsign-file-read-tokio.workspace = true -reqsign-http-send-reqwest.workspace = true +reqsign-file-read-tokio = { workspace = true } +reqsign-http-send-reqwest = { workspace = true } tokio = { version = "1", features = ["test-util", "macros", "rt-multi-thread"] } diff --git a/services/oracle/src/config.rs b/services/oracle/src/config.rs index e53c277..ffa521b 100644 --- a/services/oracle/src/config.rs +++ b/services/oracle/src/config.rs @@ -19,9 +19,9 @@ use crate::constants::*; use ini::Ini; -use reqsign_core::utils::Redact; use reqsign_core::Context; use reqsign_core::Result; +use reqsign_core::utils::Redact; use std::fmt::{Debug, Formatter}; /// Config for Oracle Cloud Infrastructure services. diff --git a/services/oracle/src/credential.rs b/services/oracle/src/credential.rs index eb9731c..a43052a 100644 --- a/services/oracle/src/credential.rs +++ b/services/oracle/src/credential.rs @@ -15,9 +15,9 @@ // specific language governing permissions and limitations // under the License. -use reqsign_core::time::{now, Timestamp}; -use reqsign_core::utils::Redact; use reqsign_core::SigningCredential; +use reqsign_core::time::{Timestamp, now}; +use reqsign_core::utils::Redact; use std::fmt::{Debug, Formatter}; /// Credential that holds the API private key information. diff --git a/services/oracle/src/provide_credential/config_file.rs b/services/oracle/src/provide_credential/config_file.rs index 8b7ebea..a222b5f 100644 --- a/services/oracle/src/provide_credential/config_file.rs +++ b/services/oracle/src/provide_credential/config_file.rs @@ -15,10 +15,10 @@ // specific language governing permissions and limitations // under the License. +use crate::Credential; use crate::constants::{ ORACLE_CONFIG_FILE, ORACLE_CONFIG_PATH, ORACLE_DEFAULT_PROFILE, ORACLE_PROFILE, }; -use crate::Credential; use async_trait::async_trait; use log::debug; use reqsign_core::{Context, ProvideCredential, Result}; diff --git a/services/oracle/src/provide_credential/default.rs b/services/oracle/src/provide_credential/default.rs index 83c7c3c..e7265ad 100644 --- a/services/oracle/src/provide_credential/default.rs +++ b/services/oracle/src/provide_credential/default.rs @@ -15,8 +15,8 @@ // specific language governing permissions and limitations // under the License. -use crate::provide_credential::{ConfigFileCredentialProvider, EnvCredentialProvider}; use crate::Credential; +use crate::provide_credential::{ConfigFileCredentialProvider, EnvCredentialProvider}; use async_trait::async_trait; use reqsign_core::{Context, ProvideCredential, ProvideCredentialChain, Result}; diff --git a/services/oracle/src/provide_credential/env.rs b/services/oracle/src/provide_credential/env.rs index 582828d..9f3c41a 100644 --- a/services/oracle/src/provide_credential/env.rs +++ b/services/oracle/src/provide_credential/env.rs @@ -15,7 +15,7 @@ // specific language governing permissions and limitations // under the License. -use crate::{constants::*, Credential}; +use crate::{Credential, constants::*}; use async_trait::async_trait; use reqsign_core::{Context, ProvideCredential, Result}; diff --git a/services/oracle/src/sign_request.rs b/services/oracle/src/sign_request.rs index 4817b91..06ea20c 100644 --- a/services/oracle/src/sign_request.rs +++ b/services/oracle/src/sign_request.rs @@ -17,20 +17,20 @@ use crate::Credential; use async_trait::async_trait; -use base64::{engine::general_purpose, Engine as _}; +use base64::{Engine as _, engine::general_purpose}; use http::request::Parts; use http::{ - header::{AUTHORIZATION, DATE}, HeaderValue, + header::{AUTHORIZATION, DATE}, }; use log::debug; -use reqsign_core::time::{format_http_date, now}; use reqsign_core::Result; +use reqsign_core::time::{format_http_date, now}; use reqsign_core::{Context, SignRequest, SigningRequest}; use rsa::pkcs1v15::SigningKey; use rsa::sha2::Sha256; use rsa::signature::{SignatureEncoding, Signer}; -use rsa::{pkcs8::DecodePrivateKey, RsaPrivateKey}; +use rsa::{RsaPrivateKey, pkcs8::DecodePrivateKey}; use std::fmt::Write; use std::time::Duration; diff --git a/services/tencent-cos/Cargo.toml b/services/tencent-cos/Cargo.toml index f513dcc..714e798 100644 --- a/services/tencent-cos/Cargo.toml +++ b/services/tencent-cos/Cargo.toml @@ -17,35 +17,33 @@ [package] name = "reqsign-tencent-cos" -version = "1.0.0" +version = "1.1.0" + +description = "Tencent Cloud COS signing implementation for reqsign." -categories.workspace = true -description.workspace = true -documentation.workspace = true edition.workspace = true license.workspace = true repository.workspace = true - +rust-version.workspace = true [dependencies] -anyhow.workspace = true -async-trait.workspace = true -http.workspace = true -jiff.workspace = true -log.workspace = true -percent-encoding.workspace = true -reqsign-core.workspace = true -serde.workspace = true -serde_json.workspace = true - +anyhow = { workspace = true } +async-trait = { workspace = true } +http = { workspace = true } +jiff = { workspace = true } +log = { workspace = true } +percent-encoding = { workspace = true } +reqsign-core = { workspace = true } +serde = { workspace = true } +serde_json = { workspace = true } [dev-dependencies] -dotenv.workspace = true -env_logger.workspace = true -once_cell.workspace = true -reqsign-core.workspace = true -reqsign-file-read-tokio.workspace = true -reqsign-http-send-reqwest.workspace = true +dotenv = { workspace = true } +env_logger = { workspace = true } +once_cell = { workspace = true } +reqsign-core = { workspace = true } +reqsign-file-read-tokio = { workspace = true } +reqsign-http-send-reqwest = { workspace = true } reqwest = { workspace = true, features = ["rustls-tls"] } -temp-env.workspace = true +temp-env = { workspace = true } tokio = { workspace = true, features = ["full"] } diff --git a/services/tencent-cos/src/credential.rs b/services/tencent-cos/src/credential.rs index cb317b0..1c04713 100644 --- a/services/tencent-cos/src/credential.rs +++ b/services/tencent-cos/src/credential.rs @@ -15,9 +15,9 @@ // specific language governing permissions and limitations // under the License. -use reqsign_core::time::{now, Timestamp}; -use reqsign_core::utils::Redact; use reqsign_core::SigningCredential; +use reqsign_core::time::{Timestamp, now}; +use reqsign_core::utils::Redact; use std::fmt::{Debug, Formatter}; /// Credential for Tencent COS. diff --git a/services/tencent-cos/src/provide_credential/assume_role_with_web_identity.rs b/services/tencent-cos/src/provide_credential/assume_role_with_web_identity.rs index fb00487..96cb55e 100644 --- a/services/tencent-cos/src/provide_credential/assume_role_with_web_identity.rs +++ b/services/tencent-cos/src/provide_credential/assume_role_with_web_identity.rs @@ -15,13 +15,13 @@ // specific language governing permissions and limitations // under the License. -use crate::constants::*; use crate::Credential; +use crate::constants::*; use async_trait::async_trait; use http::header::{AUTHORIZATION, CONTENT_LENGTH, CONTENT_TYPE}; use log::debug; -use reqsign_core::time::{now, parse_rfc3339}; use reqsign_core::Result; +use reqsign_core::time::{now, parse_rfc3339}; use reqsign_core::{Context, ProvideCredential}; use serde::{Deserialize, Serialize}; @@ -59,30 +59,34 @@ impl ProvideCredential for AssumeRoleWithWebIdentityCredentialProvider { .or_else(|| ctx.env_var(TKE_ROLE_SESSSION_NAME)) .unwrap_or_else(|| "reqsign".to_string()); - let (region, token_file, role_arn, provider_id) = - match (region, token_file, role_arn, provider_id) { - (Some(region), Some(token_file), Some(role_arn), Some(provider_id)) => { - (region, token_file, role_arn, provider_id) - } - (region, token_file, role_arn, provider_id) => { - let missing = [ - ("region", region.is_none()), - ("web_identity_token_file", token_file.is_none()), - ("role_arn", role_arn.is_none()), - ("provider_id", provider_id.is_none()), - ] - .iter() - .filter_map(|&(k, v)| if v { Some(k) } else { None }) - .collect::<Vec<_>>() - .join(", "); - - debug!( + let (region, token_file, role_arn, provider_id) = match ( + region, + token_file, + role_arn, + provider_id, + ) { + (Some(region), Some(token_file), Some(role_arn), Some(provider_id)) => { + (region, token_file, role_arn, provider_id) + } + (region, token_file, role_arn, provider_id) => { + let missing = [ + ("region", region.is_none()), + ("web_identity_token_file", token_file.is_none()), + ("role_arn", role_arn.is_none()), + ("provider_id", provider_id.is_none()), + ] + .iter() + .filter_map(|&(k, v)| if v { Some(k) } else { None }) + .collect::<Vec<_>>() + .join(", "); + + debug!( "assume_role_with_web_identity is not configured fully: [{missing}] is missing" ); - return Ok(None); - } - }; + return Ok(None); + } + }; let token = ctx.file_read_as_string(&token_file).await?; diff --git a/services/tencent-cos/src/provide_credential/default.rs b/services/tencent-cos/src/provide_credential/default.rs index 1dcf191..fd7e72f 100644 --- a/services/tencent-cos/src/provide_credential/default.rs +++ b/services/tencent-cos/src/provide_credential/default.rs @@ -15,10 +15,10 @@ // specific language governing permissions and limitations // under the License. +use crate::Credential; use crate::provide_credential::{ AssumeRoleWithWebIdentityCredentialProvider, EnvCredentialProvider, }; -use crate::Credential; use async_trait::async_trait; use reqsign_core::{Context, ProvideCredential, ProvideCredentialChain, Result}; diff --git a/services/tencent-cos/src/provide_credential/env.rs b/services/tencent-cos/src/provide_credential/env.rs index ba61f6f..de129dd 100644 --- a/services/tencent-cos/src/provide_credential/env.rs +++ b/services/tencent-cos/src/provide_credential/env.rs @@ -15,7 +15,7 @@ // specific language governing permissions and limitations // under the License. -use crate::{constants::*, Credential}; +use crate::{Credential, constants::*}; use async_trait::async_trait; use reqsign_core::{Context, ProvideCredential, Result}; diff --git a/services/tencent-cos/src/sign_request.rs b/services/tencent-cos/src/sign_request.rs index 779a1c7..f81249d 100644 --- a/services/tencent-cos/src/sign_request.rs +++ b/services/tencent-cos/src/sign_request.rs @@ -15,15 +15,15 @@ // specific language governing permissions and limitations // under the License. -use crate::constants::TENCENT_URI_ENCODE_SET; use crate::Credential; +use crate::constants::TENCENT_URI_ENCODE_SET; use async_trait::async_trait; use http::header::{AUTHORIZATION, DATE}; use http::request::Parts; use log::debug; use percent_encoding::{percent_decode_str, utf8_percent_encode}; use reqsign_core::hash::{hex_hmac_sha1, hex_sha1}; -use reqsign_core::time::{format_http_date, now, Timestamp}; +use reqsign_core::time::{Timestamp, format_http_date, now}; use reqsign_core::{Context, Result, SignRequest, SigningRequest}; use std::time::Duration; @@ -200,5 +200,8 @@ fn build_signature( let signature = hex_hmac_sha1(sign_key.as_bytes(), string_to_sign.as_bytes()); - format!("q-sign-algorithm=sha1&q-ak={}&q-sign-time={}&q-key-time={}&q-header-list={}&q-url-param-list={}&q-signature={}", cred.secret_id, key_time, key_time, header_list, param_list, signature) + format!( + "q-sign-algorithm=sha1&q-ak={}&q-sign-time={}&q-key-time={}&q-header-list={}&q-url-param-list={}&q-signature={}", + cred.secret_id, key_time, key_time, header_list, param_list, signature + ) } diff --git a/services/tencent-cos/tests/main.rs b/services/tencent-cos/tests/main.rs index a36bebc..cf14cfb 100644 --- a/services/tencent-cos/tests/main.rs +++ b/services/tencent-cos/tests/main.rs @@ -18,14 +18,14 @@ use std::env; use std::time::Duration; -use http::header::AUTHORIZATION; -use http::header::CONTENT_LENGTH; use http::Request; use http::StatusCode; +use http::header::AUTHORIZATION; +use http::header::CONTENT_LENGTH; use log::debug; use log::warn; -use percent_encoding::utf8_percent_encode; use percent_encoding::NON_ALPHANUMERIC; +use percent_encoding::utf8_percent_encode; use reqsign_core::Result; use reqsign_core::{Context, OsEnv, Signer}; use reqsign_file_read_tokio::TokioFileRead;
