From dac20079d9f361f4103e825500646bb3dc7a7902 Mon Sep 17 00:00:00 2001 From: RWDai <27391645+RWDai@users.noreply.github.com> Date: Thu, 22 Aug 2024 15:08:23 +0800 Subject: [PATCH 1/4] feat: sync ldap account status --- .vscode/extensions.json | 2 +- backend/basic/src/rbum/serv/rbum_set_serv.rs | 52 +++++--- backend/basic/tests/test_rbum_set.rs | 11 +- .../src/plugin/rewrite_ns_b_ip.rs | 3 +- .../flow/src/api/cc/flow_cc_model_api.rs | 23 +++- .../flow/src/api/ci/flow_ci_model_api.rs | 23 +++- .../flow/src/serv/flow_inst_serv.rs | 2 +- .../flow/src/serv/flow_model_serv.rs | 35 ++++- .../src/serv/obs/object_obs_obj_serv.rs | 7 +- .../src/serv/pg/search_pg_item_serv.rs | 2 +- .../spi/spi-stats/src/dto/stats_record_dto.rs | 6 +- .../iam/src/basic/serv/iam_cert_ldap_serv.rs | 123 +++++++++--------- .../serv/iam_cc_account_task_serv.rs | 2 +- .../src/console_system/api/iam_cs_res_api.rs | 2 +- backend/supports/iam/tests/test_cc_set.rs | 23 +++- 15 files changed, 203 insertions(+), 113 deletions(-) diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 90f5f346b..23ad04bbc 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -3,7 +3,7 @@ "rust-lang.rust-analyzer", "tamasfe.even-better-toml", "jscearcy.rust-doc-viewer", - "serayuzgur.crates", + "fill-labs.dependi", "belfz.search-crates-io", "vadimcn.vscode-lldb", "swellaby.vscode-rust-test-adapter", diff --git a/backend/basic/src/rbum/serv/rbum_set_serv.rs b/backend/basic/src/rbum/serv/rbum_set_serv.rs index eda0e6157..a81f38e68 100644 --- a/backend/basic/src/rbum/serv/rbum_set_serv.rs +++ b/backend/basic/src/rbum/serv/rbum_set_serv.rs @@ -498,13 +498,19 @@ impl RbumCrudOperation TardisResult<()> { assert_eq!(rbum.rel_rbum_item_name, "用户1"); info!("【test_rbum_set_item】 : Test Modify : RbumSetItemServ::modify_rbum"); - RbumSetItemServ::modify_rbum(&id, &mut RbumSetItemModifyReq { sort: Some(10), rel_rbum_set_cate_id: None, }, &funs, context).await?; + RbumSetItemServ::modify_rbum( + &id, + &mut RbumSetItemModifyReq { + sort: Some(10), + rel_rbum_set_cate_id: None, + }, + &funs, + context, + ) + .await?; info!("【test_rbum_set_item】 : Test Find : RbumSetItemServ::paginate_rbums"); let rbums = RbumSetItemServ::paginate_rbums( diff --git a/backend/gateways/spacegate-plugins/src/plugin/rewrite_ns_b_ip.rs b/backend/gateways/spacegate-plugins/src/plugin/rewrite_ns_b_ip.rs index 61036a669..f45bd0966 100644 --- a/backend/gateways/spacegate-plugins/src/plugin/rewrite_ns_b_ip.rs +++ b/backend/gateways/spacegate-plugins/src/plugin/rewrite_ns_b_ip.rs @@ -99,8 +99,7 @@ impl Plugin for RewriteNsPlugin { } impl RewriteNsPlugin { fn req(&self, req: &mut SgRequest) -> Result<(), BoxError> { - let original_ip = req - .extract::().into_inner(); + let original_ip = req.extract::().into_inner(); if self.ip_list.iter().any(|ipnet| ipnet.contains(&original_ip)) { let defer = req.extensions_mut().get_or_insert_default::(); let target_ns = self.target_ns.clone(); diff --git a/backend/middlewares/flow/src/api/cc/flow_cc_model_api.rs b/backend/middlewares/flow/src/api/cc/flow_cc_model_api.rs index 696282237..6fbbe2228 100644 --- a/backend/middlewares/flow/src/api/cc/flow_cc_model_api.rs +++ b/backend/middlewares/flow/src/api/cc/flow_cc_model_api.rs @@ -373,14 +373,21 @@ impl FlowCcModelApi { let mut funs = flow_constants::get_tardis_inst(); let global_ctx = TardisContext::default(); funs.begin().await?; - let rels = RbumRelServ::find_rels(&RbumRelFilterReq { - basic: RbumBasicFilterReq { - with_sub_own_paths: true, + let rels = RbumRelServ::find_rels( + &RbumRelFilterReq { + basic: RbumBasicFilterReq { + with_sub_own_paths: true, + ..Default::default() + }, + tag: Some("FlowModelPath".to_string()), ..Default::default() }, - tag: Some("FlowModelPath".to_string()), - ..Default::default() - }, None, None, &funs, &global_ctx).await?; + None, + None, + &funs, + &global_ctx, + ) + .await?; for rel in rels { let ctx = TardisContext { own_paths: rel.rel.own_paths, @@ -388,7 +395,9 @@ impl FlowCcModelApi { ..Default::default() }; let rel_model_id = rel.rel.from_rbum_id; - if let Some(template_id) = FlowRelServ::find_from_simple_rels(&FlowRelKind::FlowModelTemplate, &rel_model_id, None, None, &funs, &ctx).await?.pop().map(|rel| rel.rel_id) { + if let Some(template_id) = + FlowRelServ::find_from_simple_rels(&FlowRelKind::FlowModelTemplate, &rel_model_id, None, None, &funs, &ctx).await?.pop().map(|rel| rel.rel_id) + { FlowRelServ::add_simple_rel( &FlowRelKind::FlowAppTemplate, &rel.rel.to_rbum_item_id.split('/').collect::>().last().map(|s| s.to_string()).unwrap_or_default(), diff --git a/backend/middlewares/flow/src/api/ci/flow_ci_model_api.rs b/backend/middlewares/flow/src/api/ci/flow_ci_model_api.rs index dc5ff3614..02e9adb2a 100644 --- a/backend/middlewares/flow/src/api/ci/flow_ci_model_api.rs +++ b/backend/middlewares/flow/src/api/ci/flow_ci_model_api.rs @@ -299,14 +299,21 @@ impl FlowCiModelApi { let mut funs = flow_constants::get_tardis_inst(); let global_ctx = TardisContext::default(); funs.begin().await?; - let rels = RbumRelServ::find_rels(&RbumRelFilterReq { - basic: RbumBasicFilterReq { - with_sub_own_paths: true, + let rels = RbumRelServ::find_rels( + &RbumRelFilterReq { + basic: RbumBasicFilterReq { + with_sub_own_paths: true, + ..Default::default() + }, + tag: Some("FlowModelPath".to_string()), ..Default::default() }, - tag: Some("FlowModelPath".to_string()), - ..Default::default() - }, None, None, &funs, &global_ctx).await?; + None, + None, + &funs, + &global_ctx, + ) + .await?; for rel in rels { let ctx = TardisContext { own_paths: rel.rel.own_paths, @@ -314,7 +321,9 @@ impl FlowCiModelApi { ..Default::default() }; let rel_model_id = rel.rel.from_rbum_id; - if let Some(template_id) = FlowRelServ::find_from_simple_rels(&FlowRelKind::FlowModelTemplate, &rel_model_id, None, None, &funs, &ctx).await?.pop().map(|rel| rel.rel_id) { + if let Some(template_id) = + FlowRelServ::find_from_simple_rels(&FlowRelKind::FlowModelTemplate, &rel_model_id, None, None, &funs, &ctx).await?.pop().map(|rel| rel.rel_id) + { FlowRelServ::add_simple_rel( &FlowRelKind::FlowAppTemplate, &rel.rel.to_rbum_item_id.split('/').collect::>().last().map(|s| s.to_string()).unwrap_or_default(), diff --git a/backend/middlewares/flow/src/serv/flow_inst_serv.rs b/backend/middlewares/flow/src/serv/flow_inst_serv.rs index efb89692a..38ff87321 100644 --- a/backend/middlewares/flow/src/serv/flow_inst_serv.rs +++ b/backend/middlewares/flow/src/serv/flow_inst_serv.rs @@ -1236,7 +1236,7 @@ impl FlowInstServ { insts .iter() .map(|inst| async { - let mock_ctx = TardisContext{ + let mock_ctx = TardisContext { own_paths: inst.own_paths.clone(), ..ctx.clone() }; diff --git a/backend/middlewares/flow/src/serv/flow_model_serv.rs b/backend/middlewares/flow/src/serv/flow_model_serv.rs index 383a6292c..0d73f8332 100644 --- a/backend/middlewares/flow/src/serv/flow_model_serv.rs +++ b/backend/middlewares/flow/src/serv/flow_model_serv.rs @@ -1109,8 +1109,18 @@ impl FlowModelServ { ) .await? } else { - if let Some(template_id) = FlowRelServ::find_from_simple_rels(&FlowRelKind::FlowModelTemplate, rel_model_id, None, None, funs, ctx).await?.pop().map(|rel| rel.rel_id) { - if !FlowRelServ::exist_rels(&FlowRelKind::FlowAppTemplate, &template_id, Self::get_app_id_by_ctx(ctx).unwrap_or_default().as_str(), funs, ctx).await? { + if let Some(template_id) = + FlowRelServ::find_from_simple_rels(&FlowRelKind::FlowModelTemplate, rel_model_id, None, None, funs, ctx).await?.pop().map(|rel| rel.rel_id) + { + if !FlowRelServ::exist_rels( + &FlowRelKind::FlowAppTemplate, + &template_id, + Self::get_app_id_by_ctx(ctx).unwrap_or_default().as_str(), + funs, + ctx, + ) + .await? + { FlowRelServ::add_simple_rel( &FlowRelKind::FlowAppTemplate, Self::get_app_id_by_ctx(&mock_ctx).unwrap_or_default().as_str(), @@ -1671,8 +1681,25 @@ impl FlowModelServ { } } else { // clean reference template rel - for rel in FlowRelServ::find_from_simple_rels(&FlowRelKind::FlowAppTemplate, Self::get_app_id_by_ctx(&ctx).unwrap_or_default().as_str(), None, None, funs, &global_ctx).await?.into_iter() { - FlowRelServ::delete_simple_rel(&FlowRelKind::FlowAppTemplate, Self::get_app_id_by_ctx(&ctx).unwrap_or_default().as_str(), &rel.rel_id, funs, &global_ctx).await?; + for rel in FlowRelServ::find_from_simple_rels( + &FlowRelKind::FlowAppTemplate, + Self::get_app_id_by_ctx(&ctx).unwrap_or_default().as_str(), + None, + None, + funs, + &global_ctx, + ) + .await? + .into_iter() + { + FlowRelServ::delete_simple_rel( + &FlowRelKind::FlowAppTemplate, + Self::get_app_id_by_ctx(&ctx).unwrap_or_default().as_str(), + &rel.rel_id, + funs, + &global_ctx, + ) + .await?; } } if ctx.own_paths == model.own_paths { diff --git a/backend/spi/spi-object/src/serv/obs/object_obs_obj_serv.rs b/backend/spi/spi-object/src/serv/obs/object_obs_obj_serv.rs index a99a93c3e..f32e7ae02 100644 --- a/backend/spi/spi-object/src/serv/obs/object_obs_obj_serv.rs +++ b/backend/spi/spi-object/src/serv/obs/object_obs_obj_serv.rs @@ -1,9 +1,4 @@ -use tardis::{ - basic::{result::TardisResult}, - os::{ - os_client::TardisOSClient, - }, -}; +use tardis::{basic::result::TardisResult, os::os_client::TardisOSClient}; use crate::serv::s3::S3; diff --git a/backend/spi/spi-search/src/serv/pg/search_pg_item_serv.rs b/backend/spi/spi-search/src/serv/pg/search_pg_item_serv.rs index 8cbe4c2d3..0470508d3 100644 --- a/backend/spi/spi-search/src/serv/pg/search_pg_item_serv.rs +++ b/backend/spi/spi-search/src/serv/pg/search_pg_item_serv.rs @@ -1615,7 +1615,7 @@ pub async fn refresh_tsv(tag: &str, funs: &TardisFunsInst, ctx: &TardisContext, let mut page = 0; let page_size = 2000; loop { - let current_result = &result[((page*page_size).min(max_size))..(((page+1)*page_size).min(max_size))]; + let current_result = &result[((page * page_size).min(max_size))..(((page + 1) * page_size).min(max_size))]; if current_result.is_empty() { break; } diff --git a/backend/spi/spi-stats/src/dto/stats_record_dto.rs b/backend/spi/spi-stats/src/dto/stats_record_dto.rs index 130d7569c..7f7b53f7c 100644 --- a/backend/spi/spi-stats/src/dto/stats_record_dto.rs +++ b/backend/spi/spi-stats/src/dto/stats_record_dto.rs @@ -22,11 +22,11 @@ pub struct StatsFactRecordLoadReq { /// ignore updates /// ps: If idempotent_id has a value and the record is hit, this field takes effect to ignore or update, default is true to ignore updates - /// + /// /// 忽略更新 /// ps: 如果 idempotent_id 有值并且命中纪录,则该字段生效忽略或者进行更新,默认为 true 忽略更新 pub ignore_updates: Option, - + /// Field data /// 字段数据 /// @@ -57,7 +57,7 @@ pub struct StatsFactRecordsLoadReq { pub idempotent_id: Option, /// ignore updates /// ps: If idempotent_id has a value and the record is hit, this field takes effect to ignore or update, default is true to ignore updates - /// + /// /// 忽略更新 /// ps: 如果 idempotent_id 有值并且命中纪录,则该字段生效忽略或者进行更新,默认为 true 忽略更新 pub ignore_updates: Option, diff --git a/backend/supports/iam/src/basic/serv/iam_cert_ldap_serv.rs b/backend/supports/iam/src/basic/serv/iam_cert_ldap_serv.rs index 62e8a853b..1c97dcfd3 100644 --- a/backend/supports/iam/src/basic/serv/iam_cert_ldap_serv.rs +++ b/backend/supports/iam/src/basic/serv/iam_cert_ldap_serv.rs @@ -762,74 +762,77 @@ impl IamCertLdapServ { if let Some(iam_account_ext_sys_resp) = ldap_id_to_account_map.get(&local_ldap_id) { //并集 两边都有相同的账号 - //更新用户名 - // let modify_result = IamAccountServ::modify_account_agg( - // &cert.rel_rbum_id, - // &IamAccountAggModifyReq { - // name: Some(TrimString(iam_account_ext_sys_resp.display_name.clone())), - // scope_level: None, - // disabled: None, - // icon: None, - // role_ids: None, - // org_cate_ids: None, - // exts: None, - // }, - // &funs, - // ctx, - // ) - // .await; - // if modify_result.is_err() { - // let err_msg = format!("modify user name id:{} failed:{}", cert.rel_rbum_id, modify_result.err().unwrap()); - // tardis::log::error!("{}", err_msg); - // msg = format!("{msg}{err_msg}\n"); - // funs.rollback().await?; - // ldap_id_to_account_map.remove(&local_ldap_id); - // continue; - // } - if !iam_account_ext_sys_resp.labor_type.is_empty() { - let modify_result = IamAccountServ::modify_account_agg( - &cert.rel_rbum_id, - &IamAccountAggModifyReq { - labor_type: Some(iam_account_ext_sys_resp.labor_type.clone()), + if let Ok(Some(local_account)) = IamAccountServ::find_one_item( + &IamAccountFilterReq { + basic: RbumBasicFilterReq { + ids: Some(vec![]), ..Default::default() }, - &funs, - ctx, - ) - .await; - if modify_result.is_err() { - let err_msg = format!("modify labor_type id:{} failed:{}", cert.rel_rbum_id, modify_result.err().unwrap()); - tardis::log::error!("{}", err_msg); - msg = format!("{msg}{err_msg}\n"); - funs.rollback().await?; - ldap_id_to_account_map.remove(&local_ldap_id); - continue; - } - IamSearchClient::add_or_modify_account_search( - IamAccountServ::get_account_detail_aggs( - &cert.rel_rbum_id, - &IamAccountFilterReq { - basic: RbumBasicFilterReq { - ignore_scope: true, - own_paths: Some("".to_string()), - with_sub_own_paths: true, + ..Default::default() + }, + &funs, + ctx, + ) + .await + { + //判断是否需要更新labor_type、status等 + //如果需要更新其他信息,比如用户名也写在这里面 + if (!iam_account_ext_sys_resp.labor_type.is_empty() && iam_account_ext_sys_resp.labor_type != local_account.labor_type) + || local_account.status == IamAccountStatusKind::Logout + { + let mut account_modify_req = IamAccountAggModifyReq { + labor_type: Some(iam_account_ext_sys_resp.labor_type.clone()), + ..Default::default() + }; + if !iam_account_ext_sys_resp.labor_type.is_empty() && iam_account_ext_sys_resp.labor_type != local_account.labor_type { + account_modify_req.labor_type = Some(iam_account_ext_sys_resp.labor_type.clone()); + } + if local_account.status == IamAccountStatusKind::Logout { + account_modify_req.status = Some(IamAccountStatusKind::Active); + account_modify_req.logout_type = Some(IamAccountLogoutTypeKind::NotLogout); + } + let modify_result = IamAccountServ::modify_account_agg(&cert.rel_rbum_id, &account_modify_req, &funs, ctx).await; + if modify_result.is_err() { + let err_msg = format!("modify account info id:{} failed:{}", cert.rel_rbum_id, modify_result.err().unwrap()); + tardis::log::error!("{}", err_msg); + msg = format!("{msg}{err_msg}\n"); + funs.rollback().await?; + ldap_id_to_account_map.remove(&local_ldap_id); + continue; + } + IamSearchClient::add_or_modify_account_search( + IamAccountServ::get_account_detail_aggs( + &cert.rel_rbum_id, + &IamAccountFilterReq { + basic: RbumBasicFilterReq { + ignore_scope: true, + own_paths: Some("".to_string()), + with_sub_own_paths: true, + ..Default::default() + }, ..Default::default() }, - ..Default::default() - }, - true, - true, + true, + true, + &funs, + ctx, + ) + .await?, + Box::new(true), + "", &funs, ctx, ) - .await?, - Box::new(true), - "", - &funs, - ctx, - ) - .await?; + .await?; + } + } else { + let err_msg = format!("get user info failed, id:{} ", cert.rel_rbum_id); + msg = format!("{msg}{err_msg}\n"); + funs.rollback().await?; + ldap_id_to_account_map.remove(&local_ldap_id); + continue; } + if !iam_account_ext_sys_resp.mobile.is_empty() { // 如果有手机号配置那么就更新手机号 let phone_cert_conf_id = IamCertServ::get_cert_conf_id_by_kind(&IamCertKernelKind::PhoneVCode.to_string(), Some(ctx.own_paths.clone()), &funs).await?; diff --git a/backend/supports/iam/src/console_common/serv/iam_cc_account_task_serv.rs b/backend/supports/iam/src/console_common/serv/iam_cc_account_task_serv.rs index 14ecaa4f5..c838c94f7 100644 --- a/backend/supports/iam/src/console_common/serv/iam_cc_account_task_serv.rs +++ b/backend/supports/iam/src/console_common/serv/iam_cc_account_task_serv.rs @@ -76,7 +76,7 @@ impl IamCcAccountTaskServ { .await?; Ok(None) } - + pub async fn execute_account_task(funs: &TardisFunsInst, ctx: &TardisContext) -> TardisResult> { let task_ctx = ctx.clone(); TaskProcessor::execute_task_with_ctx( diff --git a/backend/supports/iam/src/console_system/api/iam_cs_res_api.rs b/backend/supports/iam/src/console_system/api/iam_cs_res_api.rs index 3f2b40025..6162ab863 100644 --- a/backend/supports/iam/src/console_system/api/iam_cs_res_api.rs +++ b/backend/supports/iam/src/console_system/api/iam_cs_res_api.rs @@ -343,7 +343,7 @@ impl IamCsResApi { } /// Modify Parent Cate Id By Res Cate Id - /// + /// #[oai(path = "/cate/:id/parent/:parent_cate_id", method = "put")] async fn move_set_cate(&self, id: Path, parent_cate_id: Path, ctx: TardisContextExtractor, request: &Request) -> TardisApiResult { try_set_real_ip_from_req_to_ctx(request, &ctx.0).await?; diff --git a/backend/supports/iam/tests/test_cc_set.rs b/backend/supports/iam/tests/test_cc_set.rs index b02227025..813a26b34 100644 --- a/backend/supports/iam/tests/test_cc_set.rs +++ b/backend/supports/iam/tests/test_cc_set.rs @@ -182,8 +182,27 @@ async fn test_single_level(context: &TardisContext, another_context: &TardisCont .is_err()); info!("【test_ca_set】 : test_single_level : Modify Set Item By Id"); - assert!(IamSetServ::modify_set_item(&item_id1, &mut RbumSetItemModifyReq { sort: Some(10), rel_rbum_set_cate_id: None, }, &funs, another_context).await.is_err()); - IamSetServ::modify_set_item(&item_id1, &mut RbumSetItemModifyReq { sort: Some(10), rel_rbum_set_cate_id: None, }, &funs, context).await?; + assert!(IamSetServ::modify_set_item( + &item_id1, + &mut RbumSetItemModifyReq { + sort: Some(10), + rel_rbum_set_cate_id: None, + }, + &funs, + another_context + ) + .await + .is_err()); + IamSetServ::modify_set_item( + &item_id1, + &mut RbumSetItemModifyReq { + sort: Some(10), + rel_rbum_set_cate_id: None, + }, + &funs, + context, + ) + .await?; info!("【test_ca_set】 : test_single_level : Find Set Item"); let items = IamSetServ::find_set_items(None, Some(set_cate_id1.clone()), None, None, false, None, &funs, context).await?; From 2e0f66802887bc3e75acf66f8f07efc8652f7e3c Mon Sep 17 00:00:00 2001 From: RWDai <27391645+RWDai@users.noreply.github.com> Date: Thu, 22 Aug 2024 15:13:06 +0800 Subject: [PATCH 2/4] cargo fix --- backend/supports/iam/src/basic/serv/iam_role_serv.rs | 5 ++--- backend/supports/iam/src/basic/serv/iam_set_serv.rs | 2 +- backend/supports/iam/src/basic/serv/iam_tenant_serv.rs | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/backend/supports/iam/src/basic/serv/iam_role_serv.rs b/backend/supports/iam/src/basic/serv/iam_role_serv.rs index 01eb19c5d..adc014334 100644 --- a/backend/supports/iam/src/basic/serv/iam_role_serv.rs +++ b/backend/supports/iam/src/basic/serv/iam_role_serv.rs @@ -24,7 +24,7 @@ use bios_basic::rbum::serv::rbum_item_serv::RbumItemCrudOperation; use bios_basic::rbum::serv::rbum_rel_serv::RbumRelServ; use crate::basic::domain::iam_role; -use crate::basic::dto::iam_filer_dto::{IamAppFilterReq, IamResFilterReq, IamRoleFilterReq, IamTenantFilterReq}; +use crate::basic::dto::iam_filer_dto::{IamAppFilterReq, IamRoleFilterReq, IamTenantFilterReq}; use crate::basic::dto::iam_role_dto::{IamRoleAddReq, IamRoleAggAddReq, IamRoleAggModifyReq, IamRoleDetailResp, IamRoleModifyReq, IamRoleSummaryResp}; use crate::basic::serv::iam_app_serv::IamAppServ; use crate::basic::serv::iam_key_cache_serv::IamIdentCacheServ; @@ -32,13 +32,12 @@ use crate::basic::serv::iam_rel_serv::IamRelServ; use crate::iam_config::{IamBasicConfigApi, IamBasicInfoManager, IamConfig}; use crate::iam_constants::{self, IAM_AVATAR, RBUM_ITEM_ID_SUB_ROLE_LEN}; use crate::iam_constants::{RBUM_SCOPE_LEVEL_APP, RBUM_SCOPE_LEVEL_TENANT}; -use crate::iam_enumeration::{IamRelKind, IamResKind, IamRoleKind}; +use crate::iam_enumeration::{IamRelKind, IamRoleKind}; use super::clients::iam_kv_client::IamKvClient; use super::clients::iam_log_client::{IamLogClient, LogParamTag}; use super::clients::iam_search_client::IamSearchClient; use super::iam_cert_serv::IamCertServ; -use super::iam_res_serv::IamResServ; use super::iam_tenant_serv::IamTenantServ; pub struct IamRoleServ; diff --git a/backend/supports/iam/src/basic/serv/iam_set_serv.rs b/backend/supports/iam/src/basic/serv/iam_set_serv.rs index 63a976168..dc306299e 100644 --- a/backend/supports/iam/src/basic/serv/iam_set_serv.rs +++ b/backend/supports/iam/src/basic/serv/iam_set_serv.rs @@ -253,7 +253,7 @@ impl IamSetServ { if kind == IamSetKind::Apps.to_string() { IamKvClient::add_or_modify_key_name( &funs.conf::().spi.kv_apps_prefix.clone(), - &set_cate_id, + set_cate_id, &set_cate_item.name.clone(), None, funs, diff --git a/backend/supports/iam/src/basic/serv/iam_tenant_serv.rs b/backend/supports/iam/src/basic/serv/iam_tenant_serv.rs index 2ef73a447..e2b1ea323 100644 --- a/backend/supports/iam/src/basic/serv/iam_tenant_serv.rs +++ b/backend/supports/iam/src/basic/serv/iam_tenant_serv.rs @@ -658,7 +658,7 @@ impl IamTenantServ { ctx, ) .await?; - IamKvClient::add_or_modify_key_name(&funs.conf::().spi.kv_tenant_prefix.clone(), &tenant_id, &tenant.name, None, funs, ctx).await?; + IamKvClient::add_or_modify_key_name(&funs.conf::().spi.kv_tenant_prefix.clone(), tenant_id, &tenant.name, None, funs, ctx).await?; Ok(()) } } From e2cae6e6cb1cbce8eb29eeee186e5d8ea4564be3 Mon Sep 17 00:00:00 2001 From: RWDai <27391645+RWDai@users.noreply.github.com> Date: Thu, 22 Aug 2024 15:24:03 +0800 Subject: [PATCH 3/4] update --- backend/middlewares/flow/src/serv/flow_model_serv.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/middlewares/flow/src/serv/flow_model_serv.rs b/backend/middlewares/flow/src/serv/flow_model_serv.rs index 0d73f8332..2bba529ad 100644 --- a/backend/middlewares/flow/src/serv/flow_model_serv.rs +++ b/backend/middlewares/flow/src/serv/flow_model_serv.rs @@ -1683,7 +1683,7 @@ impl FlowModelServ { // clean reference template rel for rel in FlowRelServ::find_from_simple_rels( &FlowRelKind::FlowAppTemplate, - Self::get_app_id_by_ctx(&ctx).unwrap_or_default().as_str(), + Self::get_app_id_by_ctx(ctx).unwrap_or_default().as_str(), None, None, funs, @@ -1694,7 +1694,7 @@ impl FlowModelServ { { FlowRelServ::delete_simple_rel( &FlowRelKind::FlowAppTemplate, - Self::get_app_id_by_ctx(&ctx).unwrap_or_default().as_str(), + Self::get_app_id_by_ctx(ctx).unwrap_or_default().as_str(), &rel.rel_id, funs, &global_ctx, From 297f48131b52f7ffc3c24d557b53f2e5ae84c21d Mon Sep 17 00:00:00 2001 From: RWDai <27391645+RWDai@users.noreply.github.com> Date: Thu, 22 Aug 2024 15:35:01 +0800 Subject: [PATCH 4/4] update --- backend/supports/iam/src/basic/serv/iam_cert_ldap_serv.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/backend/supports/iam/src/basic/serv/iam_cert_ldap_serv.rs b/backend/supports/iam/src/basic/serv/iam_cert_ldap_serv.rs index 1c97dcfd3..9accc4f44 100644 --- a/backend/supports/iam/src/basic/serv/iam_cert_ldap_serv.rs +++ b/backend/supports/iam/src/basic/serv/iam_cert_ldap_serv.rs @@ -778,6 +778,7 @@ impl IamCertLdapServ { //判断是否需要更新labor_type、status等 //如果需要更新其他信息,比如用户名也写在这里面 if (!iam_account_ext_sys_resp.labor_type.is_empty() && iam_account_ext_sys_resp.labor_type != local_account.labor_type) + || local_account.disabled || local_account.status == IamAccountStatusKind::Logout { let mut account_modify_req = IamAccountAggModifyReq { @@ -787,9 +788,10 @@ impl IamCertLdapServ { if !iam_account_ext_sys_resp.labor_type.is_empty() && iam_account_ext_sys_resp.labor_type != local_account.labor_type { account_modify_req.labor_type = Some(iam_account_ext_sys_resp.labor_type.clone()); } - if local_account.status == IamAccountStatusKind::Logout { + if local_account.disabled || local_account.status == IamAccountStatusKind::Logout { account_modify_req.status = Some(IamAccountStatusKind::Active); account_modify_req.logout_type = Some(IamAccountLogoutTypeKind::NotLogout); + account_modify_req.disabled = Some(false); } let modify_result = IamAccountServ::modify_account_agg(&cert.rel_rbum_id, &account_modify_req, &funs, ctx).await; if modify_result.is_err() {