68 lines
2.0 KiB
C++
68 lines
2.0 KiB
C++
#include <security/pam_appl.h>
|
|
#include <security/pam_client.h>
|
|
#include <security/pam_ext.h>
|
|
#include <security/pam_misc.h>
|
|
#include <security/pam_modules.h>
|
|
|
|
#include <rapidjson/rapidjson.h>
|
|
|
|
#include <rublon/rublon.hpp>
|
|
#include <rublon/utils.hpp>
|
|
#include <rublon/pam.hpp>
|
|
|
|
#include <rublon/init.hpp>
|
|
|
|
#define DLL_PUBLIC __attribute__((visibility("default")))
|
|
|
|
using namespace std;
|
|
|
|
namespace {
|
|
|
|
template < typename T >
|
|
using Expected = tl::expected< T, rublon::PamAction >;
|
|
|
|
} // namespace
|
|
|
|
DLL_PUBLIC int pam_sm_setcred([[maybe_unused]] pam_handle_t * pamh,
|
|
[[maybe_unused]] int flags,
|
|
[[maybe_unused]] int argc,
|
|
[[maybe_unused]] const char ** argv) {
|
|
return PAM_SUCCESS;
|
|
}
|
|
|
|
DLL_PUBLIC int pam_sm_acct_mgmt([[maybe_unused]] pam_handle_t * pamh,
|
|
[[maybe_unused]] int flags,
|
|
[[maybe_unused]] int argc,
|
|
[[maybe_unused]] const char ** argv) {
|
|
return PAM_SUCCESS;
|
|
}
|
|
|
|
DLL_PUBLIC int
|
|
pam_sm_authenticate(pam_handle_t * pamh, [[maybe_unused]] int flags, [[maybe_unused]] int argc, [[maybe_unused]] const char ** argv) {
|
|
rublon::log(rublon::LogLevel::Debug, "pam start");
|
|
|
|
auto rublonConfig = rublon::ConfigurationFactory{}.systemConfig();
|
|
|
|
rublon::CoreHandler CH{rublonConfig.value()};
|
|
rublon::LinuxPam pam{pamh};
|
|
|
|
auto selectMethod = [&](const rublon::MethodSelect & selector) { return selector.create(pam, std::string{""}); };
|
|
auto confirmMethod = [&](const rublon::PostMethod<rublon::LinuxPam> & confirm) { return confirm.fire(CH); };
|
|
|
|
auto method = rublon::Init{pam, rublonConfig.value()}
|
|
.fire(CH) //
|
|
.and_then(selectMethod)
|
|
.and_then(confirmMethod);
|
|
|
|
method.value().fire(CH);
|
|
|
|
rublon::log(rublon::LogLevel::Debug, "Method");
|
|
|
|
method.value().fire(CH);
|
|
|
|
// .and_then([](const auto & value) { return tl::expected< rublon::Configuration, rublon::PamAction >{}; }) //
|
|
// .and_then([](const auto & conf) { return tl::expected< rublon::Configuration, rublon::PamAction >{}; });
|
|
|
|
return PAM_SUCCESS;
|
|
}
|