MCPcopy Create free account
hub / github.com/ElementsProject/elements / RPCAuthorized

Function RPCAuthorized

src/httprpc.cpp:128–145  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

126}
127
128static bool RPCAuthorized(const std::string& strAuth, std::string& strAuthUsernameOut)
129{
130 if (strRPCUserColonPass.empty()) // Belt-and-suspenders measure if InitRPCAuthentication was not called
131 return false;
132 if (strAuth.substr(0, 6) != "Basic ")
133 return false;
134 std::string strUserPass64 = TrimString(strAuth.substr(6));
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
147static bool HTTPReq_JSONRPC(const std::any& context, HTTPRequest* req)
148{

Callers 1

HTTPReq_JSONRPCFunction · 0.85

Calls 6

TrimStringFunction · 0.85
DecodeBase64Function · 0.85
TimingResistantEqualFunction · 0.85
multiUserAuthorizedFunction · 0.85
findMethod · 0.80
emptyMethod · 0.45

Tested by

no test coverage detected