Files
spark/src/lib/utils/AuthSessionManager.h
T

38 lines
860 B
C++

#pragma once
#include "lib/api/services/AuthService.pb.h"
#include "lib/api/services/AdminService.client.pb.h"
#include "lib/utils/datetime.h"
#include <string>
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, const admin::BTSUser& user, 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<uint32_t, Session> SessionMap;
SessionMap _map;
uint32_t _nusers;
datetime::LLDateTime _expiration;
bool _concurrent;
};
}}}