summaryrefslogtreecommitdiff
path: root/redfish-core
diff options
context:
space:
mode:
authorJiaqing Zhao <jiaqing.zhao@intel.com>2022-09-29 10:31:09 +0300
committerEd Tanous <ed@tanous.net>2022-10-25 22:30:32 +0300
commit99612247f847877cc06a0277714d77e5e6cdae27 (patch)
treec4b6738e9ea90f47e3ae669c1cf3790df1be4bbe /redfish-core
parent77b364371531be5c61d84d5e83dfd72444434dd0 (diff)
downloadbmcweb-99612247f847877cc06a0277714d77e5e6cdae27.tar.xz
certificate: Allow deleting LDAP client certificate
Users should be able to delete LDAP client certificate, and phosphor- certificate-manager already supports this. This patch adds the Redfish API endpoint for it. Tested: DELETE /redfish/v1/AccountService/LDAP/Certificates/1 removes the LDAP client certificate installed on system. Change-Id: If1c082c78c404b5877e74ba50de3a970cd823a90 Signed-off-by: Jiaqing Zhao <jiaqing.zhao@intel.com>
Diffstat (limited to 'redfish-core')
-rw-r--r--redfish-core/lib/certificate_service.hpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/redfish-core/lib/certificate_service.hpp b/redfish-core/lib/certificate_service.hpp
index cb8979277e..24c84ebb93 100644
--- a/redfish-core/lib/certificate_service.hpp
+++ b/redfish-core/lib/certificate_service.hpp
@@ -1068,6 +1068,22 @@ inline void handleLDAPCertificateGet(
certURL, "LDAP Certificate");
}
+inline void handleLDAPCertificateDelete(
+ App& app, const crow::Request& req,
+ const std::shared_ptr<bmcweb::AsyncResp>& asyncResp, const std::string& id)
+{
+ if (!redfish::setUpRedfishRoute(app, req, asyncResp))
+ {
+ return;
+ }
+
+ BMCWEB_LOG_DEBUG << "Delete LDAP Certificate ID=" << id;
+ std::string objPath =
+ sdbusplus::message::object_path(certs::ldapObjectPath) / id;
+
+ deleteCertificate(asyncResp, certs::ldapServiceName, objPath);
+}
+
inline void requestRoutesLDAPCertificate(App& app)
{
BMCWEB_ROUTE(app, "/redfish/v1/AccountService/LDAP/Certificates/")
@@ -1084,6 +1100,11 @@ inline void requestRoutesLDAPCertificate(App& app)
.privileges(redfish::privileges::getCertificate)
.methods(boost::beast::http::verb::get)(
std::bind_front(handleLDAPCertificateGet, std::ref(app)));
+
+ BMCWEB_ROUTE(app, "/redfish/v1/AccountService/LDAP/Certificates/<str>/")
+ .privileges(redfish::privileges::deleteCertificate)
+ .methods(boost::beast::http::verb::delete_)(
+ std::bind_front(handleLDAPCertificateDelete, std::ref(app)));
} // requestRoutesLDAPCertificate
inline void handleTrustStoreCertificateCollectionGet(