| 125 | } |
| 126 | |
| 127 | static bool RPCAuthorized(const std::string& strAuth, std::string& strAuthUsernameOut) |
| 128 | { |
| 129 | if (strRPCUserColonPass.empty()) // Belt-and-suspenders measure if InitRPCAuthentication was not called |
| 130 | return false; |
| 131 | if (strAuth.substr(0, 6) != "Basic ") |
| 132 | return false; |
| 133 | std::string strUserPass64 = strAuth.substr(6); |
| 134 | boost::trim(strUserPass64); |
| 135 | std::string strUserPass = DecodeBase64(strUserPass64); |
| 136 | |
| 137 | if (strUserPass.find(':') != std::string::npos) |
| 138 | strAuthUsernameOut = strUserPass.substr(0, strUserPass.find(':')); |
| 139 | |
| 140 | //Check if authorized under single-user field |
| 141 | if (TimingResistantEqual(strUserPass, strRPCUserColonPass)) { |
| 142 | return true; |
| 143 | } |
| 144 | return multiUserAuthorized(strUserPass); |
| 145 | } |
| 146 | |
| 147 | static bool HTTPReq_JSONRPC(HTTPRequest* req, const std::string &) |
| 148 | { |
no test coverage detected