From 7bf84012bf44b8806bd005581626f9d632d57567 Mon Sep 17 00:00:00 2001 From: ZzIsGod1019 <1498852723@qq.com> Date: Thu, 4 Jan 2024 19:10:47 +0800 Subject: [PATCH] iam: fix bug (res unbind) (#575) --- spi/spi-search/src/search_constants.rs | 2 +- spi/spi-search/src/search_initializer.rs | 3 ++- support/iam/src/basic/serv/iam_rel_serv.rs | 6 +++++- .../iam/src/console_common/serv/iam_cc_account_task_serv.rs | 6 +++++- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/spi/spi-search/src/search_constants.rs b/spi/spi-search/src/search_constants.rs index 793d53c8a..e67815639 100644 --- a/spi/spi-search/src/search_constants.rs +++ b/spi/spi-search/src/search_constants.rs @@ -2,4 +2,4 @@ pub const DOMAIN_CODE: &str = "spi-search"; pub const EVENT_ADD_SEARCH: &str = "spi-search/add"; pub const EVENT_MODIFY_SEARCH: &str = "spi-search/modify"; -pub const EVENT_DELETE_SEARCH: &str = "spi-search/delete"; \ No newline at end of file +pub const EVENT_DELETE_SEARCH: &str = "spi-search/delete"; diff --git a/spi/spi-search/src/search_initializer.rs b/spi/spi-search/src/search_initializer.rs index d337e494a..2563ff54b 100644 --- a/spi/spi-search/src/search_initializer.rs +++ b/spi/spi-search/src/search_initializer.rs @@ -1,8 +1,9 @@ use bios_basic::spi::{api::spi_ci_bs_api, dto::spi_bs_dto::SpiBsCertResp, spi_constants, spi_funs::SpiBsInst, spi_initializer}; use tardis::{ basic::{dto::TardisContext, result::TardisResult}, + tokio, web::web_server::TardisWebServer, - TardisFuns, TardisFunsInst, tokio, + TardisFuns, TardisFunsInst, }; use crate::{api::ci::search_ci_item_api, search_config::SearchConfig, search_constants::DOMAIN_CODE, serv}; diff --git a/support/iam/src/basic/serv/iam_rel_serv.rs b/support/iam/src/basic/serv/iam_rel_serv.rs index 6dcefd57e..f265ff185 100644 --- a/support/iam/src/basic/serv/iam_rel_serv.rs +++ b/support/iam/src/basic/serv/iam_rel_serv.rs @@ -443,12 +443,16 @@ impl IamRelServ { .filter(|r| r != res_other_id) .collect::>(); // 5) If these associated resources are explicitly associated with API resources, they cannot be removed + let mut res_bound = false; for rel_res_id in rel_res_ids { if rel_api_res_ids.contains(&rel_res_id) { + res_bound = true; break; } } - remove_role_ids.push(rel_role_id); + if !res_bound { + remove_role_ids.push(rel_role_id); + } } // 6) Remove API resources from binding to roles in the cache IamResCacheServ::delete_res_rel( diff --git a/support/iam/src/console_common/serv/iam_cc_account_task_serv.rs b/support/iam/src/console_common/serv/iam_cc_account_task_serv.rs index 1779015f1..c0a3cd484 100644 --- a/support/iam/src/console_common/serv/iam_cc_account_task_serv.rs +++ b/support/iam/src/console_common/serv/iam_cc_account_task_serv.rs @@ -6,7 +6,11 @@ use crate::{ iam_filer_dto::IamAccountFilterReq, }, serv::{ - clients::{iam_log_client::LogParamTag, iam_search_client::IamSearchClient}, iam_account_serv::IamAccountServ, iam_platform_serv::IamPlatformServ, iam_rel_serv::IamRelServ, iam_tenant_serv::IamTenantServ, + clients::{iam_log_client::LogParamTag, iam_search_client::IamSearchClient}, + iam_account_serv::IamAccountServ, + iam_platform_serv::IamPlatformServ, + iam_rel_serv::IamRelServ, + iam_tenant_serv::IamTenantServ, }, }, iam_config::{IamBasicConfigApi, IamConfig},