Skip to content

Commit

Permalink
Added server verification logic
Browse files Browse the repository at this point in the history
  • Loading branch information
jushar committed Nov 23, 2015
1 parent 092ba78 commit f31df5f
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions MTA10_Server/mods/deathmatch/logic/CHTTPD.cpp
Expand Up @@ -117,6 +117,25 @@ HttpResponse * CHTTPD::RouteRequest ( HttpRequest * ipoHttpRequest )
ResponseCode CHTTPD::HandleRequest ( HttpRequest * ipoHttpRequest,
HttpResponse * ipoHttpResponse )
{
// Check if server verification was requested
auto keySecret = ipoHttpRequest->oRequestHeaders["key_secret"];
if ( ipoHttpRequest->sUri == "/get_verification_key_code" && keySecret != "" )
{
// Read keyfile
auto path = g_pServerInterface->GetModManager ()->GetAbsolutePath ( "verify.key" );
SString content;
SharedUtil::FileLoad ( path, content, 100 );

// Verify key_secret client header to prevent unauthorized people to steal the key
if ( keySecret == content.substr ( 0, 10 ) )
{
ipoHttpResponse->SetBody ( content, content.size () );
return HTTPRESPONSECODE_200_OK;
}
ipoHttpResponse->SetBody ( "", 0 );
return HTTPRESPONSECODE_401_UNAUTHORIZED;
}

CAccount * account = CheckAuthentication ( ipoHttpRequest );

if ( account )
Expand Down

0 comments on commit f31df5f

Please sign in to comment.