rublon-ssh/PAM/ssh/lib/pam.cpp
2023-07-21 10:55:06 +02:00

57 lines
1.8 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>
using namespace std;
namespace {
template < typename T >
using Expected = tl::expected< T, rublon::PamAction >;
Expected< rublon::Method > chooseMethod() {}
Expected< rublon::Confirm > confirm() {}
} // namespace
PAM_EXTERN int pam_sm_setcred(pam_handle_t * pamh, int flags, int argc, const char ** argv) {
rublon::debugLog("[TMP]start", __PRETTY_FUNCTION__);
return PAM_SUCCESS;
}
PAM_EXTERN int pam_sm_acct_mgmt(pam_handle_t * pamh, int flags, int argc, const char ** argv) {
rublon::debugLog("[TMP]start", __PRETTY_FUNCTION__);
return PAM_SUCCESS;
}
PAM_EXTERN int pam_sm_authenticate(pam_handle_t * pamh, int flags, int argc, const char ** argv) {
rublon::debugLog("[TMP]start", __PRETTY_FUNCTION__);
auto rublonConfig = rublon::ConfigurationFactory{}.systemConfig();
rublon::debugLog("[TMP]create core handler", "");
rublon::CoreHandler CH{rublonConfig.value()};
rublon::debugLog("[TMP]start", "");
auto action = rublon::Init{pamh, rublonConfig.value()}
.fire(CH) //
.and_then([](const auto & method) -> Expected< int > {
rublon::debugLog("[TMP]start", "init lambda");
return tl::unexpected{rublon::PamAction::accept};
});
// .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;
}