* Add phone call authentication method * Remove dynamic mem allocation from error handler * Add more error handling code * Move error handling to different file * Remove Socket IO dependency * cleanup in websocket code * Add rapidjson as cmake dependency * Added Dockerfiles as primary build system for packages * Changed policy in CMakeList to work with lower version of CMake * Fix opensuse builds * Link filesystem library in gcc 8.5 or older
44 lines
1.5 KiB
C++
44 lines
1.5 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 {
|
|
public:
|
|
const char * _name = "";
|
|
const bool _autopushPrompt = true;
|
|
|
|
WebsocketBasedAuth(Session & session, const char * name, bool autopushPrompt = true)
|
|
: AuthenticationStep(session), _name{name}, _autopushPrompt{autopushPrompt} {}
|
|
|
|
/// TODO refactor this code
|
|
template < typename Hander_t >
|
|
tl::expected< AuthenticationStatus, Error > verify(const CoreHandlerInterface< Hander_t > & coreHandler, const Pam_t & pam) const {
|
|
log(LogLevel::Info, "starting WS");
|
|
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");
|
|
|
|
RublonEventData event = coreHandler.listen();
|
|
|
|
if(event.status == transactionConfirmed ){
|
|
log(LogLevel::Debug, " transaction confirmed jupi");
|
|
return AuthenticationStatus{AuthenticationStatus::Action::Confirmed, std::string{event.accessToken.value().c_str()}};
|
|
}
|
|
log(LogLevel::Debug, " transaction denied");
|
|
return AuthenticationStatus{AuthenticationStatus::Action::Denied};
|
|
}
|
|
};
|
|
|
|
} // namespace rublon::method
|