On second thought, this is what we want.

This commit is contained in:
JoelKatz
2013-01-18 03:06:12 -08:00
parent 015d09993d
commit fd76033e55

View File

@@ -204,30 +204,20 @@ std::string DecodeBase64(std::string s)
return result; return result;
} }
void HTTPAuthorized(std::map<std::string, std::string>& mapHeaders, bool& user, bool& admin) bool HTTPAuthorized(std::map<std::string, std::string>& mapHeaders)
{ // This is currently not used { // This is currently not used
std::string strAuth = mapHeaders["authorization"]; std::string strAuth = mapHeaders["authorization"];
if (strAuth.substr(0,6) != "Basic ") if (strAuth.substr(0,6) != "Basic ")
{ return theConfig.RPC_ADMIN_USER.empty() && theConfig.RPC_ADMIN_PASSWORD.empty();
admin = theConfig.RPC_ADMIN_USER.empty() && theConfig.RPC_ADMIN_PASSWORD.empty();
user = theConfig.RPC_USER.empty() && theConfig.RPC_PASSWORD.empty();
}
std::string strUserPass64 = strAuth.substr(6); std::string strUserPass64 = strAuth.substr(6);
boost::trim(strUserPass64); boost::trim(strUserPass64);
std::string strUserPass = DecodeBase64(strUserPass64); std::string strUserPass = DecodeBase64(strUserPass64);
std::string::size_type nColon = strUserPass.find(":"); std::string::size_type nColon = strUserPass.find(":");
if (nColon == std::string::npos) if (nColon == std::string::npos)
{ return false;
admin = false;
user = false;
}
else
{
std::string strUser = strUserPass.substr(0, nColon); std::string strUser = strUserPass.substr(0, nColon);
std::string strPassword = strUserPass.substr(nColon+1); std::string strPassword = strUserPass.substr(nColon+1);
admin = (strUser == theConfig.RPC_ADMIN_USER) && (strPassword == theConfig.RPC_ADMIN_PASSWORD); return (strUser == theConfig.RPC_USER) && (strPassword == theConfig.RPC_PASSWORD);
user = (strUser == theConfig.RPC_USER) && (strPassword == theConfig.RPC_PASSWORD);
}
} }
// //