eqemu-server/loginserver/loginserver_webserver.h
Chris Miles 1a48add20e
[Loginserver] Modernize codebase (#4647)
* Beginning of cleanup

* More cleanup

* More cleanup

* Enc cleanup

* client manager cleanup

* client cleanup

* More cleanup

* More cleanup

* Cleanup

* More cleanup, account  context, account management

* Remove positional fmt bindings

* Use LoginAccountContext

* Update loginserver_webserver.cpp

* Remove comments

* Port CreateLoginServerAccount to repositories

* More cleanup

* More cleanup

* More cleanup

* More cleanup

* Remove a ton of functions

* More cleanup

* More cleanup

* More cleanup

* Cleanup SendClientAuthToWorld

* Consolidate world server logic

* Update login_accounts_repository.h

* Update login_accounts_repository.h

* Move api tokens to repositories

* Cleanup options

* Move everything else to repositories

* Update account_management.cpp

* uint64 account

* Update login_schema.sql

* Fix

* Update world_server.cpp

* auto
2025-02-06 12:47:02 -06:00

40 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 {
int id;
std::string token;
bool can_read;
bool can_write;
std::string user_agent;
std::string remote_address;
};
std::map<std::string, Token> loaded_api_tokens{};
void LoadApiTokens();
static bool TokenExists(const std::string &token);
Token GetToken(const std::string &token);
static Token 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