Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
ljl committed Mar 21, 2024
2 parents ef66316 + ad1f0de commit f29272b
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 13 deletions.
19 changes: 10 additions & 9 deletions support/iam/src/console_interface/api/iam_ci_cert_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ use crate::console_interface::serv::iam_ci_oauth2_token_serv::IamCiOauth2AkSkSer
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::{RbumCertSummaryResp, RbumCertSummaryWithSkResp};
use bios_basic::rbum::dto::rbum_cert_dto::RbumCertSummaryWithSkResp;
use bios_basic::rbum::dto::rbum_filer_dto::RbumCertFilterReq;
use bios_basic::rbum::serv::rbum_cert_serv::RbumCertServ;
use bios_basic::rbum::serv::rbum_crud_serv::RbumCrudOperation;
use tardis::basic::dto::TardisContext;
use tardis::basic::error::TardisError;
use tardis::web::context_extractor::TardisContextExtractor;
Expand Down Expand Up @@ -74,24 +76,23 @@ impl IamCiCertManageApi {
#[poem_openapi::OpenApi(prefix_path = "/ci/cert", tag = "bios_basic::ApiTag::Interface")]
impl IamCiCertApi {
#[oai(path = "/get/:id", method = "get")]
async fn get_cert_by_id(&self, id: Path<String>, ctx: TardisContextExtractor, request: &Request) -> TardisApiResult<RbumCertSummaryResp> {
async fn get_cert_by_id(&self, id: Path<String>, ctx: TardisContextExtractor, request: &Request) -> TardisApiResult<IamCertAkSkResp> {
add_remote_ip(request, &ctx.0).await?;
let funs = iam_constants::get_tardis_inst();
let result = IamCertServ::find_certs(
let ak = RbumCertServ::find_one_detail_rbum(
&RbumCertFilterReq {
id: Some(id.0),
id: Some(id.0.clone()),
..Default::default()
},
None,
None,
&funs,
&ctx.0,
)
.await?
.pop()
.ok_or_else(|| funs.err().internal_error("iam_ci_cert", "get_cert_by_id", "cert is not found", "401-iam-cert-code-not-exist"))?;
.ok_or_else(|| funs.err().internal_error("iam_ci_cert", "get_cert_by_id", "cert is not found", "401-iam-cert-code-not-exist"))?
.ak;
let sk = RbumCertServ::show_sk(&id.0, &RbumCertFilterReq::default(), &funs, &ctx.0).await?;
ctx.0.execute_task().await?;
TardisResp::ok(result)
TardisResp::ok(IamCertAkSkResp { id: id.clone(), ak, sk })
}
/// Find Cert By Kind And Supplier
///
Expand Down
21 changes: 17 additions & 4 deletions support/iam/src/console_interface/api/iam_ci_role_api.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
use crate::basic::dto::iam_role_dto::IamRoleRelAccountCertResp;
use bios_basic::rbum::serv::rbum_crud_serv::RbumCrudOperation;
use bios_basic::rbum::serv::rbum_item_serv::RbumItemServ;
use itertools::Itertools;

use crate::basic::serv::iam_app_serv::IamAppServ;
Expand Down Expand Up @@ -150,12 +152,23 @@ impl IamCiRoleApi {
TardisResp::ok(Void {})
}

/// get Rel Account by role_id
#[oai(path = "/:role_id/accounts", method = "get")]
async fn get_rel_accounts(&self, role_id: Path<String>, ctx: TardisContextExtractor, request: &Request) -> TardisApiResult<Vec<IamRoleRelAccountCertResp>> {
/// get Rel Account by role_code
#[oai(path = "/:role_code/accounts", method = "get")]
async fn get_rel_accounts(&self, role_code: Path<String>, ctx: TardisContextExtractor, request: &Request) -> TardisApiResult<Vec<IamRoleRelAccountCertResp>> {
add_remote_ip(request, &ctx.0).await?;
let funs = iam_constants::get_tardis_inst();
let account_ids = IamRoleServ::find_id_rel_accounts(&role_id.0, None, None, &funs, &ctx.0).await?;
let role_id = RbumItemServ::find_one_rbum(
&RbumBasicFilterReq {
code: Some(role_code.0),
..Default::default()
},
&funs,
&ctx.0,
)
.await?
.ok_or_else(|| funs.err().internal_error("iam_ci_role", "get_rel_accounts", "role is not found", "404-iam-res-not-exist"))?
.id;
let account_ids = IamRoleServ::find_id_rel_accounts(&role_id, None, None, &funs, &ctx.0).await?;
let certs = IamCertServ::find_certs(
&RbumCertFilterReq {
basic: RbumBasicFilterReq {
Expand Down

0 comments on commit f29272b

Please sign in to comment.