rublon-ssh/PAM/ssh/include/rublon/method/websocket_based_auth.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.4 KiB
C++

#pragma once
#include <tl/expected.hpp>
#include <rublon/authentication_step_interface.hpp>
#include <rublon/bits.hpp>
#include <rublon/configuration.hpp>
#include <rublon/pam_action.hpp>
#include <rublon/websockets.hpp>
namespace rublon::method {
class WebsocketBasedAuth : public AuthenticationStep {
tl::expected< void, Error > prompt(const Pam_t & pam) const {
if(not _session.inInteractiveMode()) {
return {};
}
if(not _autopushPrompt)
pam.print("Autopush");
else
pam.scan([](const auto /*ignored userinput*/) { return ""; },
"Rublon authentication initiated. Complete the authentication and press Enter to proceed");
return {};
}
public:
const char * _name = "";
const bool _autopushPrompt = true;
WebsocketBasedAuth(Session & session, const char * name, bool autopushPrompt = true)
: AuthenticationStep(session), _name{name}, _autopushPrompt{autopushPrompt} {}
template < typename Hander_t >
tl::expected< AuthenticationStatus, Error > verify(const CoreHandlerInterface< Hander_t > & coreHandler, const Pam_t & pam) const {
const auto promprUser = [&]() { return prompt(pam); };
const auto waitForCoreToConfirm = [&]() { return waitForCoreConfirmation(coreHandler); };
return promprUser() //
.and_then(waitForCoreToConfirm);
}
};
} // namespace rublon::method