aboutsummaryrefslogtreecommitdiff
path: root/NorthstarDLL/server/auth/serverauthentication.h
diff options
context:
space:
mode:
authorEmma Miler <emma.pi@protonmail.com>2022-12-19 19:32:16 +0100
committerGitHub <noreply@github.com>2022-12-19 19:32:16 +0100
commite04f3b36accccb590a2d51b4829256b9964ac3fd (patch)
tree20ee30c82e6f53e6e772be2e1b9613eebca12bf3 /NorthstarDLL/server/auth/serverauthentication.h
parent33f18a735986dcd136bf8ba70ad8331306c28227 (diff)
downloadNorthstarLauncher-e04f3b36accccb590a2d51b4829256b9964ac3fd.tar.gz
NorthstarLauncher-e04f3b36accccb590a2d51b4829256b9964ac3fd.zip
Restructuring (#365)
* Remove launcher proxy * Restructuring * More restructuring * Fix include dirs * Fix merge * Remove clang thing * Filters * Oops
Diffstat (limited to 'NorthstarDLL/server/auth/serverauthentication.h')
-rw-r--r--NorthstarDLL/server/auth/serverauthentication.h59
1 files changed, 59 insertions, 0 deletions
diff --git a/NorthstarDLL/server/auth/serverauthentication.h b/NorthstarDLL/server/auth/serverauthentication.h
new file mode 100644
index 00000000..4ffbbfd6
--- /dev/null
+++ b/NorthstarDLL/server/auth/serverauthentication.h
@@ -0,0 +1,59 @@
+#pragma once
+#include "core/convar/convar.h"
+#include "httplib.h"
+#include "engine/r2engine.h"
+#include <unordered_map>
+#include <string>
+
+struct RemoteAuthData
+{
+ char uid[33];
+ char username[64];
+
+ // pdata
+ char* pdata;
+ size_t pdataSize;
+};
+
+struct PlayerAuthenticationData
+{
+ bool usingLocalPdata;
+ size_t pdataSize;
+ bool needPersistenceWriteOnLeave = true;
+};
+
+typedef int64_t (*CBaseServer__RejectConnectionType)(void* a1, unsigned int a2, void* a3, const char* a4, ...);
+extern CBaseServer__RejectConnectionType CBaseServer__RejectConnection;
+
+class ServerAuthenticationManager
+{
+ private:
+ httplib::Server m_PlayerAuthServer;
+
+ public:
+ ConVar* Cvar_ns_player_auth_port;
+ ConVar* Cvar_ns_erase_auth_info;
+ ConVar* CVar_ns_auth_allow_insecure;
+ ConVar* CVar_ns_auth_allow_insecure_write;
+
+ std::mutex m_AuthDataMutex;
+ std::unordered_map<std::string, RemoteAuthData> m_RemoteAuthenticationData;
+ std::unordered_map<R2::CBaseClient*, PlayerAuthenticationData> m_PlayerAuthenticationData;
+ bool m_bAllowDuplicateAccounts = false;
+ bool m_bRunningPlayerAuthThread = false;
+ bool m_bNeedLocalAuthForNewgame = false;
+ bool m_bForceResetLocalPlayerPersistence = false;
+
+ public:
+ void StartPlayerAuthServer();
+ void StopPlayerAuthServer();
+ void AddPlayer(R2::CBaseClient* player, const char* pToken);
+ void RemovePlayer(R2::CBaseClient* player);
+ bool CheckDuplicateAccounts(R2::CBaseClient* player);
+ bool AuthenticatePlayer(R2::CBaseClient* player, uint64_t uid, char* authToken);
+ bool VerifyPlayerName(const char* authToken, const char* name);
+ bool RemovePlayerAuthData(R2::CBaseClient* player);
+ void WritePersistentData(R2::CBaseClient* player);
+};
+
+extern ServerAuthenticationManager* g_pServerAuthentication;