feat: admin permission check (#1783)

Signed-off-by: GatewayJ <835269233@qq.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: houseme <housemecn@gmail.com>
This commit is contained in:
GatewayJ
2026-02-25 11:58:30 +08:00
committed by GitHub
parent 0d9e5f1e93
commit 62b51b5649
6 changed files with 140 additions and 56 deletions
+12 -14
View File
@@ -52,15 +52,14 @@ pub async fn validate_admin_request(
remote_addr,
};
for action in actions {
match check_admin_request_auth(iam_store.clone(), &ctx, action, "", "").await {
Ok(_) => return Ok(()),
Err(_) => {
continue;
}
for action in &actions {
if check_admin_request_auth(iam_store.clone(), &ctx, *action, "", "")
.await
.is_ok()
{
return Ok(());
}
}
Err(s3_error!(AccessDenied, "Access Denied"))
}
@@ -113,14 +112,13 @@ pub async fn validate_admin_request_with_bucket(
remote_addr,
};
for action in actions {
match check_admin_request_auth(iam_store.clone(), &ctx, action, bucket, "").await {
Ok(_) => return Ok(()),
Err(_) => {
continue;
}
for action in &actions {
if check_admin_request_auth(iam_store.clone(), &ctx, *action, bucket, "")
.await
.is_ok()
{
return Ok(());
}
}
Err(s3_error!(AccessDenied, "Access Denied"))
}
+1 -2
View File
@@ -196,9 +196,8 @@ impl Operation for AddCannedPolicy {
})?;
if policy.version.is_empty() {
return Err(s3_error!(InvalidRequest, "policy version is empty"));
return Err(s3_error!(InvalidArgument, "policy version is empty"));
}
let Ok(iam_store) = rustfs_iam::get() else { return Err(s3_error!(InternalError, "iam not init")) };
iam_store.set_policy(&query.name, policy).await.map_err(|e| {