From b47f1d4f81a4a78048036f2b53beb1ee62d213e1 Mon Sep 17 00:00:00 2001 From: pg9182 <96569817+pg9182@users.noreply.github.com> Date: Sat, 26 Nov 2022 19:47:41 -0500 Subject: [PATCH] Add X-Northstar-Server-Id header to auth server responses This will allow Atlas to verify the correct auth server for the gameserver is listening on the expected port. --- NorthstarDLL/serverauthentication.cpp | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/NorthstarDLL/serverauthentication.cpp b/NorthstarDLL/serverauthentication.cpp index 350d85212d..fd040b9f60 100644 --- a/NorthstarDLL/serverauthentication.cpp +++ b/NorthstarDLL/serverauthentication.cpp @@ -50,20 +50,28 @@ void ServerAuthenticationManager::StartPlayerAuthServer() m_PlayerAuthServer.Get( "/verify", [](const httplib::Request& request, httplib::Response& response) - { response.set_content(AUTHSERVER_VERIFY_STRING, "text/plain"); }); + { + if (g_pMasterServerManager && *g_pMasterServerManager->m_sOwnServerId) + response.set_header("X-Northstar-Server-Id", g_pMasterServerManager->m_sOwnServerId); + + response.set_content(AUTHSERVER_VERIFY_STRING, "text/plain"); + }); m_PlayerAuthServer.Post( "/authenticate_incoming_player", [this](const httplib::Request& request, httplib::Response& response) { - if (!request.has_param("id") || !request.has_param("authToken") || request.body.size() >= R2::PERSISTENCE_MAX_SIZE || - !request.has_param("serverAuthToken") || + if (!g_pMasterServerManager || !request.has_param("id") || !request.has_param("authToken") || + request.body.size() >= R2::PERSISTENCE_MAX_SIZE || !request.has_param("serverAuthToken") || strcmp(g_pMasterServerManager->m_sOwnServerAuthToken, request.get_param_value("serverAuthToken").c_str())) { response.set_content("{\"success\":false}", "application/json"); return; } + if (*g_pMasterServerManager->m_sOwnServerId) + response.set_header("X-Northstar-Server-Id", g_pMasterServerManager->m_sOwnServerId); + RemoteAuthData newAuthData {}; strncpy_s(newAuthData.uid, sizeof(newAuthData.uid), request.get_param_value("id").c_str(), sizeof(newAuthData.uid) - 1); strncpy_s(