mirror of
https://github.com/rustfs/rustfs.git
synced 2026-08-06 13:27:43 +00:00
fix(auth): route ListBuckets denial through ApiError to hold s3s ratchet (#5755)
fix(auth): route ListBuckets auth denial through ApiError to keep s3s ratchet at baseline PR #5726 added one s3_error! call in authorize_request while PR #5739 froze the s3_error! line baseline at 1686 counted before that merge, so a clean main-derived branch fails the s3s footprint ratchet with +1. Replace the new macro call with ApiError::access_denied().into(), a small constructor on the gateway-side error abstraction (rustfs/backlog#1677 F1, rustfs/backlog#1733) instead of raising the baseline. The converted S3Error carries the identical AccessDenied code and "Access Denied" message, and the filtered ListBuckets fallback matches on the code only.
This commit is contained in:
@@ -33,6 +33,16 @@ impl std::fmt::Display for ApiError {
|
||||
impl std::error::Error for ApiError {}
|
||||
|
||||
impl ApiError {
|
||||
/// Access-denied error with the exact message emitted by the authorization
|
||||
/// paths in `storage::access`; callers there match on the code only.
|
||||
pub fn access_denied() -> Self {
|
||||
ApiError {
|
||||
code: S3ErrorCode::AccessDenied,
|
||||
message: "Access Denied".to_string(),
|
||||
source: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn other<E>(error: E) -> Self
|
||||
where
|
||||
E: std::fmt::Display + Into<Box<dyn std::error::Error + Send + Sync>>,
|
||||
|
||||
@@ -859,7 +859,7 @@ pub async fn authorize_request<T>(req: &mut S3Request<T>, action: Action) -> S3R
|
||||
}
|
||||
|
||||
if action == Action::S3Action(S3Action::ListAllMyBucketsAction) {
|
||||
return Err(s3_error!(AccessDenied, "Access Denied"));
|
||||
return Err(ApiError::access_denied().into());
|
||||
}
|
||||
|
||||
let policy_allowed_fallback = PolicySys::try_is_allowed(&BucketPolicyArgs {
|
||||
|
||||
Reference in New Issue
Block a user