diff --git a/engine/server/application/LoginServer/src/shared/ConfigLoginServer.cpp b/engine/server/application/LoginServer/src/shared/ConfigLoginServer.cpp index 457d8b59..24367e9f 100755 --- a/engine/server/application/LoginServer/src/shared/ConfigLoginServer.cpp +++ b/engine/server/application/LoginServer/src/shared/ConfigLoginServer.cpp @@ -86,6 +86,8 @@ 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); diff --git a/engine/server/application/LoginServer/src/shared/ConfigLoginServer.h b/engine/server/application/LoginServer/src/shared/ConfigLoginServer.h index 28d05bec..3a84098a 100755 --- a/engine/server/application/LoginServer/src/shared/ConfigLoginServer.h +++ b/engine/server/application/LoginServer/src/shared/ConfigLoginServer.h @@ -19,6 +19,8 @@ class ConfigLoginServer int pingServicePort; int httpServicePort; bool validateClientVersion; + bool validateStationKey; + bool doSessionLogin; bool doConsumption; const char * sessionServers; int sessionType; @@ -75,6 +77,8 @@ 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(); @@ -203,6 +207,20 @@ 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); diff --git a/engine/server/application/LoginServer/src/shared/LoginServer.cpp b/engine/server/application/LoginServer/src/shared/LoginServer.cpp index d4d1f0bf..72201382 100755 --- a/engine/server/application/LoginServer/src/shared/LoginServer.cpp +++ b/engine/server/application/LoginServer/src/shared/LoginServer.cpp @@ -193,6 +193,11 @@ m_soeMonitor(0) connectToMessage("FeatureIdTransactionRequest"); connectToMessage("FeatureIdTransactionSyncUpdate"); keyServer = new KeyServer; + + if (ConfigLoginServer::getValidateStationKey() || ConfigLoginServer::getDoSessionLogin()) + { + installSessionValidation(); + } } //----------------------------------------------------------------------- @@ -254,6 +259,30 @@ void LoginServer::removeClient (int clientId) //----------------------------------------------------------------------- +void LoginServer::installSessionValidation() +{ + int i = 0; + std::vector 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); @@ -1345,12 +1374,33 @@ void LoginServer::onValidateClient(StationId suid, const std::string & username, IGNORE_RETURN(memset(keyBuffer, 0, len)); - // 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 (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 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 + } KeyShare::Token token = LoginServer::getInstance().makeToken(keyBuffer, len); Archive::ByteStream a; diff --git a/engine/server/application/LoginServer/src/shared/LoginServer.h b/engine/server/application/LoginServer/src/shared/LoginServer.h index f17db0d2..f1d4de5b 100755 --- a/engine/server/application/LoginServer/src/shared/LoginServer.h +++ b/engine/server/application/LoginServer/src/shared/LoginServer.h @@ -139,6 +139,7 @@ private: typedef std::map ActiveClientsType; private: + void installSessionValidation(); ClusterListEntry * findClusterById (uint32 clusterId); ClusterListEntry * findClusterByName (const std::string & clusterName); ClusterListEntry * findClusterByConnection (const CentralServerConnection *connection); diff --git a/engine/server/application/LoginServer/src/shared/PurgeManager.cpp b/engine/server/application/LoginServer/src/shared/PurgeManager.cpp index 043d468f..2d649c52 100755 --- a/engine/server/application/LoginServer/src/shared/PurgeManager.cpp +++ b/engine/server/application/LoginServer/src/shared/PurgeManager.cpp @@ -120,7 +120,10 @@ void PurgeManager::onGetAccountForPurge(StationId account, int purgePhase) PurgeRecord record(account, static_cast(purgePhase)); m_purgeRecords.insert(std::make_pair(account,record)); - onCheckStatusForPurge(account, false); + if (ConfigLoginServer::getValidateStationKey()) + NON_NULL(LoginServer::getInstance().getSessionApiClient())->checkStatusForPurge(account); + else + onCheckStatusForPurge(account, false); } }