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:
唐小鸭
2026-08-06 03:22:28 +08:00
committed by GitHub
parent 5f3bc617fe
commit ea8dbf49a2
2 changed files with 11 additions and 1 deletions
+10
View File
@@ -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>>,
+1 -1
View File
@@ -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 {