-
-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(s3s): split access from auth
- Loading branch information
Showing
6 changed files
with
55 additions
and
31 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 |
---|---|---|
@@ -0,0 +1,32 @@ | ||
mod context; | ||
pub use self::context::S3AccessContext; | ||
|
||
use crate::error::S3Result; | ||
|
||
#[async_trait::async_trait] | ||
pub trait S3Access: Send + Sync + 'static { | ||
/// Checks whether the current request have accesses to the resources. | ||
/// | ||
/// This method is called before deserializing the operation input. | ||
/// | ||
/// By default, this method rejects all anonymous requests | ||
/// and returns [`AccessDenied`](crate::S3ErrorCode::AccessDenied) error. | ||
/// | ||
/// An access control provider can override this method to implement custom logic. | ||
/// | ||
/// Common fields in the context: | ||
/// + [`cx.credentials()`](S3AccessContext::credentials) | ||
/// + [`cx.s3_path()`](S3AccessContext::s3_path) | ||
/// + [`cx.s3_op().name()`](crate::S3Operation::name) | ||
/// + [`cx.extensions_mut()`](S3AccessContext::extensions_mut) | ||
async fn check(&self, cx: &mut S3AccessContext<'_>) -> S3Result<()> { | ||
default_check(cx) | ||
} | ||
} | ||
|
||
pub(crate) fn default_check(cx: &mut S3AccessContext<'_>) -> S3Result<()> { | ||
match cx.credentials() { | ||
Some(_) => Ok(()), | ||
None => Err(s3_error!(AccessDenied, "Signature is required")), | ||
} | ||
} |
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 |
---|---|---|
|
@@ -36,6 +36,7 @@ mod sig_v2; | |
mod sig_v4; | ||
mod xml; | ||
|
||
pub mod access; | ||
pub mod auth; | ||
pub mod checksum; | ||
pub mod dto; | ||
|
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