-
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
background: apache/opendal#4960 (comment) this PR introduced a Sign trait, which is suitable on the cases like when we want customize signing logics like apache/iceberg-rust#506
- Loading branch information
1 parent
6ffbb8a
commit d85f554
Showing
4 changed files
with
120 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -89,4 +89,6 @@ mod ctx; | |
mod dirs; | ||
mod hash; | ||
mod request; | ||
mod sign; | ||
mod time; | ||
pub use sign::Sign; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
use std::time::Duration; | ||
|
||
/// Sign will be a trait that implement by all services providers supported by reqsign, user | ||
/// can implement their own too. It will take http::request::Parts and services Credential | ||
/// to perform sign over this request. | ||
#[async_trait::async_trait] | ||
pub trait Sign: Send + Sync + Unpin + 'static { | ||
/// Credential type for this signer. | ||
type Credential: Send + Sync + Unpin + 'static; | ||
|
||
/// Sign the request with headers. | ||
async fn sign( | ||
&self, | ||
req: &mut http::request::Parts, | ||
cred: &Self::Credential, | ||
) -> anyhow::Result<()>; | ||
|
||
/// Sign the request with query parameters. | ||
async fn sign_query( | ||
&self, | ||
req: &mut http::request::Parts, | ||
expires: Duration, | ||
cred: &Self::Credential, | ||
) -> anyhow::Result<()>; | ||
} |