Require Steam validation before granting admin access (bug 4837, r=asherkin).
authorRyan Stecker <voidedweasel@gmail.com>
Thu May 24 17:55:46 2012 +0100 (2012-05-24)
changeset 35022c1c30b50acc
parent 3501 ba91db6d6c23
child 3503 08b1578a8363
Require Steam validation before granting admin access (bug 4837, r=asherkin).
core/PlayerManager.cpp
core/PlayerManager.h
     1.1 --- a/core/PlayerManager.cpp	Thu May 24 16:09:44 2012 +0100
     1.2 +++ b/core/PlayerManager.cpp	Thu May 24 17:55:46 2012 +0100
     1.3 @@ -116,6 +116,8 @@
     1.4  	m_SourceTVUserId = -1;
     1.5  	m_ReplayUserId = -1;
     1.6  
     1.7 +	m_bUseSteamAdminAuth = true; // use steam auth by default
     1.8 +
     1.9  	m_UserIdLookUp = new int[USHRT_MAX+1];
    1.10  	memset(m_UserIdLookUp, 0, sizeof(int) * (USHRT_MAX+1));
    1.11  }
    1.12 @@ -229,6 +231,17 @@
    1.13  			return ConfigResult_Reject;
    1.14  		}
    1.15  		return ConfigResult_Accept;
    1.16 +	} else if (strcmp( key, "SteamAuthstringValidation" ) == 0) {
    1.17 +		if (strcasecmp(value, "yes") == 0)
    1.18 +		{
    1.19 +			m_bUseSteamAdminAuth = true;
    1.20 +		} else if ( strcasecmp(value, "no") == 0) {
    1.21 +			m_bUseSteamAdminAuth = false;
    1.22 +		} else {
    1.23 +			UTIL_Format(error, maxlength, "Invalid value: must be \"yes\" or \"no\"");
    1.24 +			return ConfigResult_Reject;
    1.25 +		}
    1.26 +		return ConfigResult_Accept;
    1.27  	}
    1.28  	return ConfigResult_Ignore;
    1.29  }
    1.30 @@ -354,6 +367,18 @@
    1.31  	{
    1.32  		pPlayer = &m_Players[m_AuthQueue[i]];
    1.33  		authstr = engine->GetPlayerNetworkIDString(pPlayer->m_pEdict);
    1.34 +
    1.35 +#if SOURCE_ENGINE >= SE_ORANGEBOX
    1.36 +		// we can only easily check if the client is fully authed if we're on a recent engine
    1.37 +		if (m_bUseSteamAdminAuth && !g_HL2.IsLANServer())
    1.38 +		{
    1.39 +			if (!pPlayer->IsAuthedBySteam())
    1.40 +			{
    1.41 +				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
    1.42 +			}
    1.43 +		}
    1.44 +#endif
    1.45 +
    1.46  		if (authstr && authstr[0] != '\0'
    1.47  			&& (strcmp(authstr, "STEAM_ID_PENDING") != 0))
    1.48  		{
    1.49 @@ -1632,6 +1657,13 @@
    1.50  	return m_IsAuthorized;
    1.51  }
    1.52  
    1.53 +#if SOURCE_ENGINE >= SE_ORANGEBOX
    1.54 +bool CPlayer::IsAuthedBySteam()
    1.55 +{
    1.56 +	return engine->IsClientFullyAuthenticated( m_pEdict );
    1.57 +}
    1.58 +#endif
    1.59 +
    1.60  IPlayerInfo *CPlayer::GetPlayerInfo()
    1.61  {
    1.62  	if (m_pEdict->GetUnknown())
     2.1 --- a/core/PlayerManager.h	Thu May 24 16:09:44 2012 +0100
     2.2 +++ b/core/PlayerManager.h	Thu May 24 17:55:46 2012 +0100
     2.3 @@ -75,6 +75,9 @@
     2.4  	bool WasCountedAsInGame();
     2.5  	bool IsConnected();
     2.6  	bool IsAuthorized();
     2.7 +#if SOURCE_ENGINE >= SE_ORANGEBOX
     2.8 +	bool IsAuthedBySteam();
     2.9 +#endif
    2.10  	bool IsFakeClient();
    2.11  	bool IsSourceTV() const;
    2.12  	bool IsReplay() const;
    2.13 @@ -217,6 +220,7 @@
    2.14  	unsigned int *m_AuthQueue;
    2.15  	String m_PassInfoVar;
    2.16  	bool m_QueryLang;
    2.17 +	bool m_bUseSteamAdminAuth; // are we validating admins with steam before authorizing?
    2.18  	bool m_bIsListenServer;
    2.19  	int m_ListenClient;
    2.20  	bool m_bIsSourceTVActive;