refactor(admin): extract user IAM route registration (#1794)

This commit is contained in:
安正超
2026-02-13 12:35:59 +08:00
committed by GitHub
parent 2fc36bb52e
commit cbb4329428
3 changed files with 39 additions and 18 deletions
+1
View File
@@ -36,6 +36,7 @@ pub mod system;
pub mod tier;
pub mod trace;
pub mod user;
pub mod user_iam;
#[cfg(test)]
mod tests {
+2 -18
View File
@@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.
use super::{account_info, event, group, policies, service_account};
use super::{account_info, event, group, policies, service_account, user_iam};
use crate::{
admin::{
auth::validate_admin_request,
@@ -61,7 +61,7 @@ pub fn register_user_route(r: &mut S3Router<AdminOperation>) -> std::io::Result<
register_user_management_route(r)?;
group::register_group_management_route(r)?;
service_account::register_service_account_route(r)?;
register_user_iam_route(r)?;
user_iam::register_user_iam_route(r)?;
policies::register_iam_policy_route(r)?;
event::register_notification_target_route(r)?;
@@ -102,22 +102,6 @@ fn register_user_management_route(r: &mut S3Router<AdminOperation>) -> std::io::
Ok(())
}
fn register_user_iam_route(r: &mut S3Router<AdminOperation>) -> std::io::Result<()> {
r.insert(
Method::GET,
format!("{}{}", ADMIN_PREFIX, "/v3/export-iam").as_str(),
AdminOperation(&ExportIam {}),
)?;
r.insert(
Method::PUT,
format!("{}{}", ADMIN_PREFIX, "/v3/import-iam").as_str(),
AdminOperation(&ImportIam {}),
)?;
Ok(())
}
pub struct AddUser {}
#[async_trait::async_trait]
impl Operation for AddUser {
+36
View File
@@ -0,0 +1,36 @@
// Copyright 2024 RustFS Team
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
use super::user::{ExportIam, ImportIam};
use crate::{
admin::router::{AdminOperation, S3Router},
server::ADMIN_PREFIX,
};
use hyper::Method;
pub fn register_user_iam_route(r: &mut S3Router<AdminOperation>) -> std::io::Result<()> {
r.insert(
Method::GET,
format!("{}{}", ADMIN_PREFIX, "/v3/export-iam").as_str(),
AdminOperation(&ExportIam {}),
)?;
r.insert(
Method::PUT,
format!("{}{}", ADMIN_PREFIX, "/v3/import-iam").as_str(),
AdminOperation(&ImportIam {}),
)?;
Ok(())
}