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

46 lines
1001 B
C++

#pragma once
#ifndef _WIN32
#include "lib/api/services/AdminService.client.pb.h"
#include "lib/api/services/AuthService.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 std::string &username = "",
std::string *msg = nullptr);
bool check_session(const api::user::TokenPayload &tok);
void clear_sessions();
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;
};
} // namespace auth
} // namespace api
} // namespace bts
#endif