mirror of
https://github.com/SWG-Source/src.git
synced 2026-07-29 23:15:56 -04:00
remove station related session code
This commit is contained in:
@@ -184,91 +184,73 @@ static size_t WriteCallback(void *contents, size_t size, size_t nmemb, void *use
|
||||
// Grab a challenge key from the list and send it back to the client.
|
||||
void ClientConnection::validateClient(const std::string & id, const std::string & key)
|
||||
{
|
||||
StationId suid = atoi(id.c_str());
|
||||
|
||||
if (ConfigLoginServer::getValidateStationKey())
|
||||
if (suid==0)
|
||||
{
|
||||
m_requestedAdminSuid = atoi(id.c_str()); // for normal logins, this will be set to 0
|
||||
|
||||
SessionApiClient * sessionApiClient = LoginServer::getInstance().getSessionApiClient();
|
||||
DEBUG_FATAL(!sessionApiClient, ("Config file says to validate with session, but no session api is installed"));
|
||||
if(sessionApiClient) //lint !e774 //(Boolean within 'if' always evaluates to True) the previous DEBUG_FATAL probably causes this warning
|
||||
sessionApiClient->validateClient(this, key);
|
||||
std::hash<std::string> h;
|
||||
suid = h(id); //lint !e603 // Symbol 'h' not initialized (it's a functor)
|
||||
}
|
||||
else if (ConfigLoginServer::getDoSessionLogin())
|
||||
|
||||
LOG("LoginClientConnection", ("validateClient() for stationId (%lu) at IP (%s), id (%s) key (%s), skipping validating session", m_stationId, getRemoteAddress().c_str(), id.c_str(), key.c_str()));
|
||||
|
||||
std::string authURL = std::string(ConfigLoginServer::getExternalAuthUrl());
|
||||
|
||||
if (ConfigLoginServer::getUseExternalAuth() == true && !(authURL.empty()))
|
||||
{
|
||||
SessionApiClient * sessionApiClient = LoginServer::getInstance().getSessionApiClient();
|
||||
DEBUG_FATAL(!sessionApiClient, ("Config file says to do session login, but no session api is installed"));
|
||||
if(sessionApiClient) //lint !e774 //(Boolean within 'if' always evaluates to True) the previous DEBUG_FATAL probably causes this warning
|
||||
sessionApiClient->loginClient(this, id, key);
|
||||
}
|
||||
else
|
||||
{
|
||||
StationId suid = atoi(id.c_str());
|
||||
CURL *curl;
|
||||
CURLcode res;
|
||||
std::string readBuffer;
|
||||
|
||||
if (suid==0)
|
||||
curl = curl_easy_init();
|
||||
|
||||
if (curl)
|
||||
{
|
||||
std::hash<std::string> h;
|
||||
suid = h(id); //lint !e603 // Symbol 'h' not initialized (it's a functor)
|
||||
}
|
||||
|
||||
LOG("LoginClientConnection", ("validateClient() for stationId (%lu) at IP (%s), id (%s) key (%s), skipping validating session", m_stationId, getRemoteAddress().c_str(), id.c_str(), key.c_str()));
|
||||
std::string username(curl_easy_escape(curl, id.c_str(), 0));
|
||||
std::string password(curl_easy_escape(curl, key.c_str(), 0));
|
||||
std::string ip(curl_easy_escape(curl, getRemoteAddress().c_str(), 0));
|
||||
|
||||
std::string authURL = std::string(ConfigLoginServer::getExternalAuthUrl());
|
||||
|
||||
if (ConfigLoginServer::getUseExternalAuth() == true && !(authURL.empty()))
|
||||
{
|
||||
CURL *curl;
|
||||
CURLcode res;
|
||||
std::string readBuffer;
|
||||
|
||||
curl = curl_easy_init();
|
||||
|
||||
if (curl)
|
||||
{
|
||||
std::string username(curl_easy_escape(curl, id.c_str(), id.length()));
|
||||
std::string password(curl_easy_escape(curl, key.c_str(), key.length()));
|
||||
|
||||
curl_easy_setopt(curl, CURLOPT_URL, (authURL + username + "&pw=" + password).c_str());
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);
|
||||
curl_easy_setopt(curl, CURLOPT_URL, (authURL + username + "&pw=" + password + "&ip=" + ip));
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, WriteCallback);
|
||||
curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer);
|
||||
|
||||
res = curl_easy_perform(curl);
|
||||
res = curl_easy_perform(curl);
|
||||
|
||||
if (res == CURLE_OK && !(readBuffer.empty()))
|
||||
if (res == CURLE_OK && !(readBuffer.empty()))
|
||||
{
|
||||
json j = json::parse(readBuffer);
|
||||
|
||||
if (j["status"] == "success")
|
||||
{
|
||||
json j = json::parse(readBuffer);
|
||||
|
||||
if (j["status"] == "success")
|
||||
{
|
||||
LoginServer::getInstance().onValidateClient(suid, id, this, true, NULL, 0xFFFFFFFF, 0xFFFFFFFF);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string errMsg = j["userMessage"];
|
||||
|
||||
if (errMsg.empty()) //prevent stupid mistakes
|
||||
{
|
||||
errMsg = "Error: authentication service provided no user message.";
|
||||
}
|
||||
|
||||
ErrorMessage err("Login Failed", errMsg);
|
||||
this->send(err, true);
|
||||
}
|
||||
|
||||
LoginServer::getInstance().onValidateClient(suid, id, this, true, NULL, 0xFFFFFFFF, 0xFFFFFFFF);
|
||||
}
|
||||
else
|
||||
{
|
||||
ErrorMessage err("Login Failed", "Error connecting to authentication service.");
|
||||
std::string errMsg = j["userMessage"];
|
||||
|
||||
if (errMsg.empty()) //prevent stupid mistakes
|
||||
{
|
||||
errMsg = "Error: authentication service provided no user message.";
|
||||
}
|
||||
|
||||
ErrorMessage err("Login Failed", errMsg);
|
||||
this->send(err, true);
|
||||
}
|
||||
|
||||
curl_easy_cleanup(curl);
|
||||
}
|
||||
else
|
||||
{
|
||||
ErrorMessage err("Login Failed", "Error connecting to authentication service.");
|
||||
this->send(err, true);
|
||||
}
|
||||
|
||||
curl_easy_cleanup(curl);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
LoginServer::getInstance().onValidateClient(suid, id, this, true, NULL, 0xFFFFFFFF, 0xFFFFFFFF);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LoginServer::getInstance().onValidateClient(suid, id, this, true, NULL, 0xFFFFFFFF, 0xFFFFFFFF);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -86,8 +86,6 @@ void ConfigLoginServer::install(void)
|
||||
KEY_INT (maxCharactersPerCluster, 10000);
|
||||
KEY_INT (maxCharactersPerAccount, 20);
|
||||
KEY_BOOL (validateClientVersion, true);
|
||||
KEY_BOOL (validateStationKey, false);
|
||||
KEY_BOOL (doSessionLogin, false);
|
||||
KEY_BOOL (doConsumption, false);
|
||||
KEY_STRING (sessionServers, "localhost:3004");
|
||||
KEY_INT (sessionType, SESSION_TYPE_STARWARS);
|
||||
|
||||
@@ -19,8 +19,6 @@ class ConfigLoginServer
|
||||
int pingServicePort;
|
||||
int httpServicePort;
|
||||
bool validateClientVersion;
|
||||
bool validateStationKey;
|
||||
bool doSessionLogin;
|
||||
bool doConsumption;
|
||||
const char * sessionServers;
|
||||
int sessionType;
|
||||
@@ -77,8 +75,6 @@ class ConfigLoginServer
|
||||
static const uint16 getPingServicePort();
|
||||
static const uint16 getHttpServicePort();
|
||||
static const bool getValidateClientVersion();
|
||||
static const bool getValidateStationKey();
|
||||
static const bool getDoSessionLogin();
|
||||
static const bool getDoConsumption();
|
||||
static const char * getSessionServers();
|
||||
static const int getSessionType();
|
||||
@@ -207,20 +203,6 @@ inline const bool ConfigLoginServer::getValidateClientVersion()
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
inline const bool ConfigLoginServer::getValidateStationKey()
|
||||
{
|
||||
return (data->validateStationKey);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
inline const bool ConfigLoginServer::getDoSessionLogin()
|
||||
{
|
||||
return (data->doSessionLogin);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
inline const bool ConfigLoginServer::getDoConsumption()
|
||||
{
|
||||
return (data->doConsumption);
|
||||
|
||||
@@ -193,11 +193,6 @@ m_soeMonitor(0)
|
||||
connectToMessage("FeatureIdTransactionRequest");
|
||||
connectToMessage("FeatureIdTransactionSyncUpdate");
|
||||
keyServer = new KeyServer;
|
||||
|
||||
if (ConfigLoginServer::getValidateStationKey() || ConfigLoginServer::getDoSessionLogin())
|
||||
{
|
||||
installSessionValidation();
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
@@ -259,30 +254,6 @@ void LoginServer::removeClient (int clientId)
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
void LoginServer::installSessionValidation()
|
||||
{
|
||||
int i = 0;
|
||||
std::vector<const char* > sessionServers;
|
||||
|
||||
int numberOfSessionServers = ConfigLoginServer::getNumberOfSessionServers();
|
||||
for (i = 0; i < numberOfSessionServers; ++i)
|
||||
{
|
||||
char const * const p = ConfigLoginServer::getSessionServer(i);
|
||||
if(p)
|
||||
{
|
||||
REPORT_LOG(true, ("Using session server %s\n", p));
|
||||
sessionServers.push_back(p);
|
||||
}
|
||||
}
|
||||
|
||||
// if there were none specified, use defaults
|
||||
FATAL(i == 0, ("No session servers specified for session API"));
|
||||
|
||||
m_sessionApiClient = new SessionApiClient(&sessionServers[0], i);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------
|
||||
|
||||
bool LoginServer::deleteCharacter(uint32 clusterId, NetworkId const & characterId, StationId suid)
|
||||
{
|
||||
const ClusterListEntry *cle = findClusterById(clusterId);
|
||||
@@ -1374,33 +1345,12 @@ void LoginServer::onValidateClient(StationId suid, const std::string & username,
|
||||
|
||||
IGNORE_RETURN(memset(keyBuffer, 0, len));
|
||||
|
||||
if (ConfigLoginServer::getDoConsumption() || ConfigLoginServer::getDoSessionLogin())
|
||||
{
|
||||
// pass the sessionkey
|
||||
len = apiSessionIdWidth + sizeof(StationId);
|
||||
memcpy(keyBufferPointer, sessionKey, apiSessionIdWidth);
|
||||
keyBufferPointer += apiSessionIdWidth;
|
||||
memcpy(keyBufferPointer, &suid, sizeof(StationId));
|
||||
|
||||
// if LoginServer did session login, send the session key back to the client;
|
||||
// the client normally gets the session key from the LaunchPad, but in this mode
|
||||
// where the LoginServer does the session login, it will get it from the LoginServer
|
||||
if (ConfigLoginServer::getDoSessionLogin())
|
||||
{
|
||||
std::string const strSessionKey(sessionKey, apiSessionIdWidth);
|
||||
GenericValueTypeMessage<std::string> const msg("SetSessionKey", strSessionKey);
|
||||
conn->send(msg, true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// If we aren't validating sessions, pack username, security status, and username to connectionserver
|
||||
memcpy(keyBufferPointer, &suid, sizeof(uint32)); //lint !e64 !e119 !e534 (lint isn't resolving memcpy properly)
|
||||
keyBufferPointer += sizeof(uint32);
|
||||
memcpy(keyBufferPointer, &isSecure, sizeof(bool)); //lint !e64 !e119 !e534
|
||||
keyBufferPointer += sizeof(bool);
|
||||
memcpy(keyBufferPointer, username.c_str(), MAX_ACCOUNT_NAME_LENGTH); //lint !e64 !e119 !e534
|
||||
}
|
||||
// If we aren't validating sessions, pack username, security status, and username to connectionserver
|
||||
memcpy(keyBufferPointer, &suid, sizeof(uint32)); //lint !e64 !e119 !e534 (lint isn't resolving memcpy properly)
|
||||
keyBufferPointer += sizeof(uint32);
|
||||
memcpy(keyBufferPointer, &isSecure, sizeof(bool)); //lint !e64 !e119 !e534
|
||||
keyBufferPointer += sizeof(bool);
|
||||
memcpy(keyBufferPointer, username.c_str(), MAX_ACCOUNT_NAME_LENGTH); //lint !e64 !e119 !e534
|
||||
|
||||
KeyShare::Token token = LoginServer::getInstance().makeToken(keyBuffer, len);
|
||||
Archive::ByteStream a;
|
||||
|
||||
@@ -139,7 +139,6 @@ private:
|
||||
typedef std::map<int, ClientConnection *> ActiveClientsType;
|
||||
|
||||
private:
|
||||
void installSessionValidation();
|
||||
ClusterListEntry * findClusterById (uint32 clusterId);
|
||||
ClusterListEntry * findClusterByName (const std::string & clusterName);
|
||||
ClusterListEntry * findClusterByConnection (const CentralServerConnection *connection);
|
||||
|
||||
@@ -120,10 +120,7 @@ void PurgeManager::onGetAccountForPurge(StationId account, int purgePhase)
|
||||
PurgeRecord record(account, static_cast<PurgePhase>(purgePhase));
|
||||
m_purgeRecords.insert(std::make_pair(account,record));
|
||||
|
||||
if (ConfigLoginServer::getValidateStationKey())
|
||||
NON_NULL(LoginServer::getInstance().getSessionApiClient())->checkStatusForPurge(account);
|
||||
else
|
||||
onCheckStatusForPurge(account, false);
|
||||
onCheckStatusForPurge(account, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user