diff options
author | Jack <66967891+ASpoonPlaysGames@users.noreply.github.com> | 2023-12-27 00:32:01 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-12-27 01:32:01 +0100 |
commit | f5ab6fb5e8be7b73e6003d4145081d5e0c0ce287 (patch) | |
tree | 90f2c6a4885dbd181799e2325cf33588697674e1 /primedev/server/auth/serverauthentication.h | |
parent | bb8ed59f6891b1196c5f5bbe7346cd171c8215fa (diff) | |
download | NorthstarLauncher-1.21.2-rc3.tar.gz NorthstarLauncher-1.21.2-rc3.zip |
Folder restructuring from primedev (#624)v1.21.2-rc3v1.21.2
Copies of over the primedev folder structure for easier cherry-picking of further changes
Co-authored-by: F1F7Y <filip.bartos07@proton.me>
Diffstat (limited to 'primedev/server/auth/serverauthentication.h')
-rw-r--r-- | primedev/server/auth/serverauthentication.h | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/primedev/server/auth/serverauthentication.h b/primedev/server/auth/serverauthentication.h new file mode 100644 index 00000000..996d20e1 --- /dev/null +++ b/primedev/server/auth/serverauthentication.h @@ -0,0 +1,58 @@ +#pragma once +#include "core/convar/convar.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 +{ +public: + 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<CBaseClient*, PlayerAuthenticationData> m_PlayerAuthenticationData; + + bool m_bAllowDuplicateAccounts = false; + bool m_bNeedLocalAuthForNewgame = false; + bool m_bForceResetLocalPlayerPersistence = false; + bool m_bStartingLocalSPGame = false; + +public: + void AddRemotePlayer(std::string token, uint64_t uid, std::string username, std::string pdata); + + void AddPlayer(CBaseClient* pPlayer, const char* pAuthToken); + void RemovePlayer(CBaseClient* pPlayer); + + bool VerifyPlayerName(const char* pAuthToken, const char* pName, char pOutVerifiedName[64]); + bool IsDuplicateAccount(CBaseClient* pPlayer, const char* pUid); + bool CheckAuthentication(CBaseClient* pPlayer, uint64_t iUid, char* pAuthToken); + + void AuthenticatePlayer(CBaseClient* pPlayer, uint64_t iUid, char* pAuthToken); + bool RemovePlayerAuthData(CBaseClient* pPlayer); + void WritePersistentData(CBaseClient* pPlayer); +}; + +extern ServerAuthenticationManager* g_pServerAuthentication; |