Skip to content

Commit

Permalink
ci-cert Api add ldap_origin param (#552)
Browse files Browse the repository at this point in the history
  • Loading branch information
RWDai authored Dec 1, 2023
1 parent 30c3461 commit 7f84c90
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 3 additions & 1 deletion support/iam/src/basic/serv/iam_cert_serv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -588,9 +588,11 @@ impl IamCertServ {
cert_supplier: Vec<String>,
cert_conf_id: Option<String>,
tenant_id: &str,
ldap_dn: bool,
funs: &TardisFunsInst,
ctx: &TardisContext,
) -> TardisResult<RbumCertSummaryWithSkResp> {
let ldap_cn = !ldap_dn;
let mut is_ldap = false;
let rbum_cert_filter_req = if let Some(cert_conf_id) = cert_conf_id {
let cert_conf = RbumCertConfServ::get_rbum(
Expand Down Expand Up @@ -635,7 +637,7 @@ impl IamCertServ {
if let Some(ext_cert) = ext_cert {
Ok(RbumCertSummaryWithSkResp {
id: ext_cert.id,
ak: if is_ldap { IamCertLdapServ::dn_to_cn(&ext_cert.ak) } else { ext_cert.ak },
ak: if is_ldap && ldap_cn { IamCertLdapServ::dn_to_cn(&ext_cert.ak) } else { ext_cert.ak },
sk: "".to_string(),
sk_invisible: ext_cert.sk_invisible,
ext: ext_cert.ext,
Expand Down
8 changes: 6 additions & 2 deletions support/iam/src/console_interface/api/iam_ci_cert_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,17 @@ impl IamCiCertApi {
/// Find Cert By Kind And Supplier
///
/// if kind is none,query default kind(UserPwd)
/// - `supplier` is only used when kind is `Ldap`
/// - `ldap_origin` is only used when kind is `Ldap` and default is false.
/// when true,return ak will be original DN
#[oai(path = "/:account_id", method = "get")]
async fn get_cert_by_kind_supplier(
&self,
account_id: Path<String>,
kind: Query<Option<String>>,
tenant_id: Query<Option<String>>,
supplier: Query<Option<String>>,
ldap_origin: Query<Option<bool>>,
ctx: TardisContextExtractor,
request: &Request,
) -> TardisApiResult<RbumCertSummaryWithSkResp> {
Expand All @@ -96,8 +100,8 @@ impl IamCiCertApi {
} else {
None
};

let cert = IamCertServ::get_cert_by_relrubmid_kind_supplier(&account_id.0, &kind, vec![supplier], conf_id, &true_tenant_id.unwrap_or_default(), &funs, &ctx.0).await?;
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?;
ctx.0.execute_task().await?;
TardisResp::ok(cert)
}
Expand Down

0 comments on commit 7f84c90

Please sign in to comment.