#pragma once #include "lib/api/services/AuthService.pb.h" #include "lib/api/services/AdminService.client.pb.h" #include "lib/utils/datetime.h" #include namespace bts { namespace config { class KeyCode; } namespace api { namespace auth { struct Session { api::user::TokenPayload token; }; class AuthSessionManager { public: AuthSessionManager(); bool add_or_replace_session(const api::user::TokenPayload& tok, std::string* msg = nullptr); bool check_session(const api::user::TokenPayload& tok); private: bool validate_ip_port(const bts::config::KeyCode& kc); private: static const std::string PUBLIC_KEY; typedef std::map SessionMap; SessionMap _map; uint32_t _nusers; datetime::LLDateTime _expiration; bool _concurrent; }; }}}