30#ifndef HORIZON_AUTH_HPP
31#define HORIZON_AUTH_HPP
90 if (!RAND_bytes(salt.data(),
SALT_LEN)) {
91 throw std::runtime_error(
"Failed to generate salt");
95 void hash_password(
const std::string& password,
const std::vector<unsigned char>& salt, std::vector<unsigned char>& hash) {
97 if (!PKCS5_PBKDF2_HMAC(password.c_str(), password.length(), salt.data(), salt.size(),
ITERATIONS, EVP_sha256(),
HASH_LEN, hash.data())) {
98 throw std::runtime_error(
"Failed to hash password");
119 void update(uint64_t time);
131#define sAuth Horizon::Auth::AuthServer::getInstance()
bool clicmd_reset_password(std::string)
Definition: Auth.cpp:204
TaskScheduler & getScheduler()
Definition: Auth.hpp:111
~AuthServer()
Horizon Destructor.
Definition: Auth.cpp:50
void hash_password(const std::string &password, const std::vector< unsigned char > &salt, std::vector< unsigned char > &hash)
Definition: Auth.hpp:95
TaskScheduler _task_scheduler
Definition: Auth.hpp:122
void initialize() override
Definition: Auth.cpp:342
std::mutex _conf_lock
Definition: Auth.hpp:123
auth_config_type & get_auth_config()
Definition: Auth.hpp:113
auth_config_type _auth_config
Definition: Auth.hpp:124
void initialize_cli_commands()
Initialize CLI Comamnds.
Definition: Auth.cpp:253
void verify_connected_sessions()
Definition: Auth.cpp:263
bool clicmd_reload_config(std::string)
CLI Command: Reload Configuration.
Definition: Auth.cpp:142
bool clicmd_create_new_account(std::string)
Definition: Auth.cpp:149
void generate_salt(std::vector< unsigned char > &salt)
Definition: Auth.hpp:88
boost::asio::deadline_timer _update_timer
Definition: Auth.hpp:125
static AuthServer * getInstance()
Definition: Auth.hpp:77
AuthServer()
Horizon Constructor.
Definition: Auth.cpp:42
void finalize() override
Definition: Auth.cpp:390
void update(uint64_t time)
Definition: Auth.cpp:311
bool read_config()
Read /config/horizon-server.yaml.
Definition: Auth.cpp:61
Definition: Server.hpp:554
The TaskScheduler class provides the ability to schedule std::function's in the near future....
Definition: TaskScheduler.hpp:58
const int HASH_LEN
Definition: Auth.hpp:68
const int ITERATIONS
Definition: Auth.hpp:69
const int SALT_LEN
Definition: Auth.hpp:67
Definition: Element.hpp:7
uint16_t _is_new
Definition: Auth.hpp:50
std::string _name
Definition: Auth.hpp:49
uint16_t _port
Definition: Auth.hpp:50
std::string _host
Definition: Auth.hpp:49
uint16_t _type
Definition: Auth.hpp:50
Main Auth Server Singleton Class.
Definition: Auth.hpp:44
void set_session_max_timeout(int timeout)
Definition: Auth.hpp:60
int _max_network_threads
Definition: Auth.hpp:63
void add_char_server(char_server c)
Definition: Auth.hpp:53
void set_max_network_threads(int threads)
Definition: Auth.hpp:57
std::vector< char_server > & get_char_servers()
Definition: Auth.hpp:54
std::string _password_salt_mix
Definition: Auth.hpp:45
int max_network_threads()
Definition: Auth.hpp:56
std::vector< char_server > _char_servers
Definition: Auth.hpp:62
int _session_max_timeout
Definition: Auth.hpp:64
int session_max_timeout()
Definition: Auth.hpp:59