rublon-ssh/PAM/ssh/include/rublon/authentication_step_interface.hpp
rublon-bwi af64f8e9e3
Bwi/v2.2.0 (#16)
* Remove dynamic memory usage from core

* Refacor status check to use json pointers

* Move access token to session

* Remove code duplication

* Fix compile warnings from rapidjson sources

* Add 'interactive mode option to session configuration

* Implement non interactive mode connector

* Add 'non interactove' implementation

* Apply rapidjson patch

* Build on all cores

* Rename build script

* Split configure and build steps

* Add scripts for building all images

* Change bash to python for build scripts

* Stop printing methods name in non interactive mode

* Add trace log level, adn more params to init message

* Fix build

* Fix non interactive method selection and refactor vagrant files for debian like systems

* Refactor log messages

* Remove exces dependencies from vagrant configuration files

* Fixed vagrantfiles

* Added repo for rhel

* Add nonInteractiveMode option

* Added instalation script for pubkey

* Fixed pubkey install script and postrm for rhel
2025-03-07 11:41:12 +01:00

46 lines
1.5 KiB
C++

#pragma once
#include <rublon/core_handler_interface.hpp>
#include <rublon/pam_action.hpp>
#include <rublon/session.hpp>
#include <rublon/utils.hpp>
namespace rublon {
class AuthenticationStep {
protected:
Session & _session;
public:
AuthenticationStep(Session & session) : _session{session} {}
protected:
void addSystemToken(Document & body) const {
auto & alloc = body.GetAllocator();
body.AddMember("systemToken", Value{_session.csystemToken(), alloc}, alloc);
}
void addTid(Document & body) const {
auto & alloc = body.GetAllocator();
body.AddMember("tid", Value{_session.ctransactionID(), alloc}, alloc);
}
void addAccessToken(Document & body, std::string_view token) const {
auto & alloc = body.GetAllocator();
body.AddMember("accessToken", Value{token.data(), static_cast< unsigned >(token.length()), alloc}, alloc);
}
template < typename Hander_t >
tl::expected< AuthenticationStatus, Error > waitForCoreConfirmation(const CoreHandlerInterface< Hander_t > & eventListener) const {
auto event = eventListener.listen();
if(event.status == transactionConfirmed ){
log(LogLevel::Debug, " Transaction confirmed");
return AuthenticationStatus{AuthenticationStatus::Action::Confirmed, std::string{event.accessToken.value().c_str()}};
}
log(LogLevel::Debug, " Transaction denied");
return AuthenticationStatus{AuthenticationStatus::Action::Denied};
}
};
} // namespace rublon