Secret Keys for auth and admin levels

This commit is contained in:
Tekaoh
2020-04-23 18:40:30 -04:00
parent aff1127b9f
commit 1bf5d9cefb
6 changed files with 21 additions and 3 deletions

View File

@@ -192,6 +192,7 @@ void ClientConnection::validateClient(const std::string & id, const std::string
api.addJsonData<std::string>("user_password", trimmedKey);
api.addJsonData<long>("stationID", suid);
api.addJsonData<std::string>("ip", getRemoteAddress());
api.addJsonData<std::string>("secretKey", ConfigLoginServer::getExternalAuthSecretKey());
if (api.submit())
{
@@ -215,7 +216,7 @@ void ClientConnection::validateClient(const std::string & id, const std::string
else
{
std::ostringstream postBuf;
postBuf << "user_name=" << trimmedId << "&user_password=" << trimmedKey << "&stationID=" << suid << "&ip=" << getRemoteAddress();
postBuf << "user_name=" << trimmedId << "&user_password=" << trimmedKey << "&stationID=" << suid << "&ip=" << getRemoteAddress() << "&secretKey=" << ConfigLoginServer::getExternalAuthSecretKey();
std::string response = webAPI::simplePost(authURL, std::string(postBuf.str()), "");
if (response == "success") {

View File

@@ -118,6 +118,7 @@ void ConfigLoginServer::install(void)
KEY_BOOL(useJsonWebApi, false);
KEY_BOOL(useExternalAuth, false);
KEY_STRING(externalAuthURL, "");
KEY_STRING(externalAuthSecretKey, "");
KEY_BOOL(useOldSuidGenerator, false);
int index = 0;

View File

@@ -66,11 +66,12 @@ class ConfigLoginServer
int csToolPort;
bool requireSecureLoginForCsTool;
bool useOldSuidGenerator;
bool useExternalAuth;
bool useJsonWebApi;
const char * externalAuthURL;
const char * externalAuthSecretKey;
};
static const uint16 getCentralServicePort();
@@ -137,6 +138,7 @@ class ConfigLoginServer
static bool getUseExternalAuth();
static bool getUseJsonWebApi();
static const char * getExternalAuthUrl();
static const char * getExternalAuthSecretKey();
static bool getUseOldSuidGenerator();
// has character creation for this cluster been disabled through config option
@@ -502,6 +504,10 @@ inline const char * ConfigLoginServer::getExternalAuthUrl()
return data->externalAuthURL;
}
inline const char * ConfigLoginServer::getExternalAuthSecretKey()
{
return data->externalAuthSecretKey;
}
inline bool ConfigLoginServer::getUseOldSuidGenerator()
{

View File

@@ -75,7 +75,7 @@ int AdminAccountManager::getAdminLevel(const std::string & account)
if(ConfigServerUtility::isExternalAdminLevelsEnabled()){
std::ostringstream postBuffer;
postBuffer << "user_name=" << account;
postBuffer << "user_name=" << account << "&secretKey=" << ConfigServerUtility::getExternalAdminLevelsSecretKey();
std::string response = webAPI::simplePost(ConfigServerUtility::getExternalAdminLevelsURL(), std::string(postBuffer.str()), "");
level = std::stoi(response);
return level;

View File

@@ -19,6 +19,7 @@ namespace ConfigServerUtilityNamespace
bool chatLogManagerLoggingEnabled;
bool externalAdminLevelsEnabled;
const char * externalAdminLevelsURL;
const char * externalAdminLevelsSecretKey;
}
using namespace ConfigServerUtilityNamespace;
@@ -91,6 +92,13 @@ const char * ConfigServerUtility::getExternalAdminLevelsURL()
//-----------------------------------------------------------------------
const char * ConfigServerUtility::getExternalAdminLevelsSecretKey()
{
return externalAdminLevelsSecretKey;
}
//-----------------------------------------------------------------------
void ConfigServerUtility::install()
{
KEY_INT(spawnCookie, 0);
@@ -100,6 +108,7 @@ void ConfigServerUtility::install()
KEY_BOOL(chatLogManagerLoggingEnabled, false);
KEY_BOOL(externalAdminLevelsEnabled, false);
KEY_STRING(externalAdminLevelsURL, "http://localhost/");
KEY_STRING(externalAdminLevelsSecretKey, "");
}
//-----------------------------------------------------------------------

View File

@@ -19,6 +19,7 @@ public:
static bool isChatLogManagerLoggingEnabled();
static bool isExternalAdminLevelsEnabled();
static const char * getExternalAdminLevelsURL();
static const char * getExternalAdminLevelsSecretKey();
static void install();
static void remove();