mirror of
https://github.com/EQEmu/Server.git
synced 2026-02-11 16:12:24 +00:00
* if for whatever reason the world server is not sending an address, use the local address it sends * Log when world is sending loginserver info * Force legacy mode when login host is login.eqemulator.net to avoid misconfigurations at least until things change * Add human IP translation to log messages * Sanitize world server name * Code cleanup and renaming member variables * More cleanup * Remove this-> * Validation constants * Key worldserver lookups by both longname and shortname both * Update allowed character list * Fix short_name API response field; add world_id to response * Shorten receiver verbosity * Remove unnecessary member variables from database and rename database to m_database * Adjust MAX_SERVER_VERSION_LENGTH * Fix indents
39 lines
1.1 KiB
C++
39 lines
1.1 KiB
C++
#ifndef EQEMU_LOGINSERVER_WEBSERVER_H
|
|
#define EQEMU_LOGINSERVER_WEBSERVER_H
|
|
|
|
#include "../common/http/httplib.h"
|
|
#include "../common/json/json.h"
|
|
#include "../common/types.h"
|
|
|
|
namespace LoginserverWebserver {
|
|
|
|
class TokenManager {
|
|
|
|
public:
|
|
TokenManager() = default;
|
|
|
|
struct token_data {
|
|
std::string token;
|
|
bool can_read;
|
|
bool can_write;
|
|
std::string user_agent;
|
|
std::string remote_address;
|
|
};
|
|
|
|
std::map<std::string, token_data> loaded_api_tokens{};
|
|
|
|
void LoadApiTokens();
|
|
static bool TokenExists(const std::string &token);
|
|
token_data GetToken(const std::string &token);
|
|
static token_data CheckApiAuthorizationHeaders(const httplib::Request &request);
|
|
static bool AuthCanRead(const httplib::Request &request, httplib::Response &res);
|
|
static bool AuthCanWrite(const httplib::Request &request, httplib::Response &res);
|
|
};
|
|
|
|
void RegisterRoutes(httplib::Server &api);
|
|
void SendResponse(const Json::Value &payload, httplib::Response &res);
|
|
static Json::Value ParseRequestBody(const httplib::Request &request);
|
|
};
|
|
|
|
#endif //EQEMU_LOGINSERVER_WEBSERVER_H
|