* Add websocket implementation * Added configuration for build socket-io and rublon connector
37 lines
1.1 KiB
C++
37 lines
1.1 KiB
C++
#pragma once
|
|
|
|
#include <tl/expected.hpp>
|
|
|
|
#include <rublon/authentication_step_interface.hpp>
|
|
#include <rublon/pam.hpp>
|
|
#include <rublon/pam_action.hpp>
|
|
|
|
#include <rublon/websockets.hpp>
|
|
|
|
namespace rublon::method {
|
|
|
|
class WebsocketBasedAuth : public AuthenticationStep< WebsocketBasedAuth > {
|
|
using base_t = AuthenticationStep< WebsocketBasedAuth >;
|
|
|
|
public:
|
|
const char * name = "";
|
|
|
|
WebsocketBasedAuth(std::string systemToken, std::string tid, const char * name)
|
|
: base_t(std::move(systemToken), std::move(tid)), name{name} {}
|
|
|
|
template < typename Hander_t, typename PamInfo_t = LinuxPam >
|
|
tl::expected< AuthenticationStatus, Error > handle(const CoreHandlerInterface< Hander_t > & /*coreHandler*/,
|
|
const PamInfo_t & pam) const {
|
|
log(LogLevel::Info, "starting WS");
|
|
|
|
WebSocket ws;
|
|
pam.print("Waiting for user approval");
|
|
auto aproved = ws.connect(this->_tid);
|
|
|
|
return aproved ? AuthenticationStatus{AuthenticationStatus::Action::Confirmed} :
|
|
AuthenticationStatus{AuthenticationStatus::Action::Denied};
|
|
}
|
|
};
|
|
|
|
} // namespace rublon::method
|