Require Steam validation before granting admin access (bug 4837, r=asherkin).

This commit is contained in:
Ryan Stecker 2012-05-24 17:55:46 +01:00
parent d77ebd60cf
commit ac2bbf16f6
2 changed files with 36 additions and 0 deletions

View File

@ -116,6 +116,8 @@ PlayerManager::PlayerManager()
m_SourceTVUserId = -1;
m_ReplayUserId = -1;
m_bUseSteamAdminAuth = true; // use steam auth by default
m_UserIdLookUp = new int[USHRT_MAX+1];
memset(m_UserIdLookUp, 0, sizeof(int) * (USHRT_MAX+1));
}
@ -229,6 +231,17 @@ ConfigResult PlayerManager::OnSourceModConfigChanged(const char *key,
return ConfigResult_Reject;
}
return ConfigResult_Accept;
} else if (strcmp( key, "SteamAuthstringValidation" ) == 0) {
if (strcasecmp(value, "yes") == 0)
{
m_bUseSteamAdminAuth = true;
} else if ( strcasecmp(value, "no") == 0) {
m_bUseSteamAdminAuth = false;
} else {
UTIL_Format(error, maxlength, "Invalid value: must be \"yes\" or \"no\"");
return ConfigResult_Reject;
}
return ConfigResult_Accept;
}
return ConfigResult_Ignore;
}
@ -354,6 +367,18 @@ void PlayerManager::RunAuthChecks()
{
pPlayer = &m_Players[m_AuthQueue[i]];
authstr = engine->GetPlayerNetworkIDString(pPlayer->m_pEdict);
#if SOURCE_ENGINE >= SE_ORANGEBOX
// we can only easily check if the client is fully authed if we're on a recent engine
if (m_bUseSteamAdminAuth && !g_HL2.IsLANServer())
{
if (!pPlayer->IsAuthedBySteam())
{
continue; // we're using steam auth, and steam doesn't know about this player yet so we can't do anything about them for now
}
}
#endif
if (authstr && authstr[0] != '\0'
&& (strcmp(authstr, "STEAM_ID_PENDING") != 0))
{
@ -1632,6 +1657,13 @@ bool CPlayer::IsAuthorized()
return m_IsAuthorized;
}
#if SOURCE_ENGINE >= SE_ORANGEBOX
bool CPlayer::IsAuthedBySteam()
{
return engine->IsClientFullyAuthenticated( m_pEdict );
}
#endif
IPlayerInfo *CPlayer::GetPlayerInfo()
{
if (m_pEdict->GetUnknown())

View File

@ -75,6 +75,9 @@ public:
bool WasCountedAsInGame();
bool IsConnected();
bool IsAuthorized();
#if SOURCE_ENGINE >= SE_ORANGEBOX
bool IsAuthedBySteam();
#endif
bool IsFakeClient();
bool IsSourceTV() const;
bool IsReplay() const;
@ -217,6 +220,7 @@ private:
unsigned int *m_AuthQueue;
String m_PassInfoVar;
bool m_QueryLang;
bool m_bUseSteamAdminAuth; // are we validating admins with steam before authorizing?
bool m_bIsListenServer;
int m_ListenClient;
bool m_bIsSourceTVActive;