rublon-ssh/PAM/ssh/include/rublon/authentication_step_interface.hpp
rublon-bwi 25b29e6f32
Bwi/logic fixes (#5)
* Code rafactoring, formating, add proper readout of operating system

* refactor
2023-10-26 10:13:01 +02:00

45 lines
1.4 KiB
C++

#pragma once
#include <rublon/core_handler_interface.hpp>
#include <rublon/pam.hpp>
#include <rublon/pam_action.hpp>
#include <rublon/utils.hpp>
namespace rublon {
template < typename Impl >
class AuthenticationStep {
protected:
std::string _systemToken;
std::string _tid;
public:
AuthenticationStep() = default;
AuthenticationStep(std::string systemToken, std::string tid) : _systemToken{std::move(systemToken)}, _tid{std::move(tid)} {}
template < typename Handler_t >
auto fire(const CoreHandlerInterface< Handler_t > & coreHandler) const {
log(LogLevel::Info, "Starting %s step", static_cast< const Impl * >(this)->name);
return static_cast< const Impl * >(this)->handle(coreHandler);
}
template < typename Handler_t, typename PamInfo_t = LinuxPam >
auto fire(const CoreHandlerInterface< Handler_t > & coreHandler, const PamInfo_t & pam) const {
log(LogLevel::Info, "Starting %s step", static_cast< const Impl * >(this)->name);
return static_cast< const Impl * >(this)->handle(coreHandler, pam);
}
protected:
void addSystemToken(Document & body) const {
auto & alloc = body.GetAllocator();
body.AddMember("systemToken", Value{this->_systemToken.c_str(), alloc}, alloc);
}
void addTid(Document & body) const {
auto & alloc = body.GetAllocator();
body.AddMember("tid", Value{this->_tid.c_str(), alloc}, alloc);
}
};
} // namespace rublon