Skip to content

Commit

Permalink
add ci ldap conf (#553)
Browse files Browse the repository at this point in the history
  • Loading branch information
RWDai authored Dec 1, 2023
1 parent 7f84c90 commit e2da286
Showing 1 changed file with 29 additions and 4 deletions.
33 changes: 29 additions & 4 deletions support/iam/src/console_interface/api/iam_ci_cert_api.rs
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
use std::collections::HashMap;

use crate::basic::dto::iam_account_dto::IamAccountExtSysResp;
use crate::basic::dto::iam_cert_conf_dto::IamCertConfLdapResp;
use crate::basic::dto::iam_cert_dto::{IamCertAkSkAddReq, IamCertAkSkResp, IamCertDecodeRequest, IamOauth2AkSkResp, IamThirdPartyCertExtAddReq};
use crate::basic::serv::iam_account_serv::IamAccountServ;
use crate::basic::serv::iam_cert_ldap_serv::IamCertLdapServ;
use crate::basic::serv::iam_cert_serv::IamCertServ;
use crate::console_interface::serv::iam_ci_cert_aksk_serv::IamCiCertAkSkServ;
use crate::console_interface::serv::iam_ci_oauth2_token_serv::IamCiOauth2AkSkServ;

use crate::iam_constants;
use crate::iam_enumeration::Oauth2GrantType;
use bios_basic::helper::request_helper::add_remote_ip;
use bios_basic::rbum::dto::rbum_cert_dto::RbumCertSummaryWithSkResp;
use tardis::basic::dto::TardisContext;
use tardis::basic::error::TardisError;
use tardis::web::context_extractor::TardisContextExtractor;
use tardis::web::poem::Request;
use tardis::web::poem_openapi;
Expand Down Expand Up @@ -101,7 +102,8 @@ impl IamCiCertApi {
None
};
let ldap_DN = ldap_origin.0.unwrap_or_default();
let cert = IamCertServ::get_cert_by_relrubmid_kind_supplier(&account_id.0, &kind, vec![supplier], conf_id, &true_tenant_id.unwrap_or_default(), ldap_DN,&funs, &ctx.0).await?;
let cert =
IamCertServ::get_cert_by_relrubmid_kind_supplier(&account_id.0, &kind, vec![supplier], conf_id, &true_tenant_id.unwrap_or_default(), ldap_DN, &funs, &ctx.0).await?;
ctx.0.execute_task().await?;
TardisResp::ok(cert)
}
Expand Down Expand Up @@ -163,10 +165,10 @@ impl IamCiCertApi {
}
}

#[poem_openapi::OpenApi(prefix_path = "/ci/ldap/cert", tag = "bios_basic::ApiTag::Interface")]
#[poem_openapi::OpenApi(prefix_path = "/ci/ldap", tag = "bios_basic::ApiTag::Interface")]
impl IamCiLdapCertApi {
/// 根据ldap cn查询对应的displayName
#[oai(path = "/cn/:cn", method = "get")]
#[oai(path = "/cert/cn/:cn", method = "get")]
async fn get_ldap_resp_by_cn(&self, cn: Path<String>) -> TardisApiResult<Vec<IamAccountExtSysResp>> {
let funs = iam_constants::get_tardis_inst();
let ctx = TardisContext {
Expand All @@ -181,4 +183,27 @@ impl IamCiLdapCertApi {
ctx.execute_task().await?;
TardisResp::ok(result)
}

/// Get Ldap Cert Conf
#[oai(path = "/conf", method = "get")]
async fn get_ldap_cert(
&self,
supplier: Query<String>,
tenant_id: Query<Option<String>>,
ctx: TardisContextExtractor,
request: &Request,
) -> TardisApiResult<IamCertConfLdapResp> {
let ctx = IamCertServ::try_use_tenant_ctx(ctx.0, tenant_id.0.clone())?;
add_remote_ip(request, &ctx).await?;
let mut funs = iam_constants::get_tardis_inst();
funs.begin().await?;
let conf_id = if let Ok(conf_id) = IamCertServ::get_cert_conf_id_by_kind_supplier("Ldap", &supplier.0, tenant_id.0, &funs).await {
conf_id
} else {
return TardisResp::err(TardisError::bad_request("ldap config not found", ""));
};
let resp = IamCertLdapServ::get_cert_conf(&conf_id, &funs, &ctx).await?;
funs.commit().await?;
TardisResp::ok(resp)
}
}

0 comments on commit e2da286

Please sign in to comment.