MCPcopy Create free account
hub / github.com/ClickHouse/ClickHouse / checkAuthentication

Method checkAuthentication

src/Server/InterserverIOHTTPHandler.cpp:29–53  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

27}
28
29std::pair<String, bool> InterserverIOHTTPHandler::checkAuthentication(HTTPServerRequest & request) const
30{
31 auto server_credentials = server.context()->getInterserverCredentials();
32 if (server_credentials)
33 {
34 if (!request.hasCredentials())
35 return server_credentials->isValidUser("", "");
36
37 String scheme;
38 String info;
39 request.getCredentials(scheme, info);
40
41 if (scheme != "Basic")
42 return {"Server requires HTTP Basic authentication but client provides another method", false};
43
44 Poco::Net::HTTPBasicCredentials credentials(info);
45 return server_credentials->isValidUser(credentials.getUsername(), credentials.getPassword());
46 }
47 if (request.hasCredentials())
48 {
49 return {"Client requires HTTP Basic authentication, but server doesn't provide it", false};
50 }
51
52 return {"", true};
53}
54
55void InterserverIOHTTPHandler::processQuery(HTTPServerRequest & request, HTTPServerResponse & response, OutputPtr output)
56{

Callers

nothing calls this directly

Calls 6

hasCredentialsMethod · 0.80
isValidUserMethod · 0.80
contextMethod · 0.45
getCredentialsMethod · 0.45
getPasswordMethod · 0.45

Tested by

no test coverage detected