MFA feature: Enable google authenticator
Enabling multi-factor authentication for BMC. This feature enables
google authenticator using TOTP method.
This commit implements interface published [here][1]
and [here][2]
The implementation supports features such as create secret key,verify
TOTP token, enable system level MFA, and enable bypass options.
Currently the support is only for GoogleAuthenticator.
[1]: https://github.com/openbmc/phosphor-dbus-interfaces/blob/master/yaml/xyz/openbmc_project/User/MultiFactorAuthConfiguration.interface.yaml
[2]: https://github.com/openbmc/phosphor-dbus-interfaces/blob/master/yaml/xyz/openbmc_project/User/TOTPAuthenticator.interface.yaml
Tested By:
Unit test
https://gerrit.openbmc.org/c/openbmc/phosphor-user-manager/+/78583/1
Change-Id: I053095763c65963ff865b487ab08f05039d2fc3a
Signed-off-by: Abhilash Raju <abhilash.kollam@gmail.com>
diff --git a/user_mgr.hpp b/user_mgr.hpp
index 701ab3b..624b2ba 100644
--- a/user_mgr.hpp
+++ b/user_mgr.hpp
@@ -26,6 +26,8 @@
#include <xyz/openbmc_project/Common/error.hpp>
#include <xyz/openbmc_project/User/AccountPolicy/server.hpp>
#include <xyz/openbmc_project/User/Manager/server.hpp>
+#include <xyz/openbmc_project/User/MultiFactorAuthConfiguration/server.hpp>
+#include <xyz/openbmc_project/User/TOTPState/server.hpp>
#include <span>
#include <string>
@@ -50,7 +52,14 @@
using AccountPolicyIface =
sdbusplus::xyz::openbmc_project::User::server::AccountPolicy;
-using Ifaces = sdbusplus::server::object_t<UserMgrIface, AccountPolicyIface>;
+using MultiFactorAuthConfigurationIface =
+ sdbusplus::xyz::openbmc_project::User::server::MultiFactorAuthConfiguration;
+
+using TOTPStateIface = sdbusplus::xyz::openbmc_project::User::server::TOTPState;
+
+using Ifaces = sdbusplus::server::object_t<UserMgrIface, AccountPolicyIface,
+ MultiFactorAuthConfigurationIface,
+ TOTPStateIface>;
using Privilege = std::string;
using GroupList = std::vector<std::string>;
@@ -73,6 +82,8 @@
using DbusUserObj = std::map<DbusUserObjPath, DbusUserObjValue>;
+using MultiFactorAuthType = sdbusplus::common::xyz::openbmc_project::user::
+ MultiFactorAuthConfiguration::Type;
std::string getCSVFromVector(std::span<const std::string> vec);
bool removeStringFromCSV(std::string& csvStr, const std::string& delStr);
@@ -259,7 +270,13 @@
void createGroup(std::string groupName) override;
void deleteGroup(std::string groupName) override;
-
+ MultiFactorAuthType enabled() const override
+ {
+ return MultiFactorAuthConfigurationIface::enabled();
+ }
+ MultiFactorAuthType enabled(MultiFactorAuthType value,
+ bool skipSignal) override;
+ bool secretKeyRequired(std::string userName) override;
static std::vector<std::string> readAllGroupsOnSystem();
protected: