MCPcopy Create free account
hub / github.com/apache/impala / GetUsernameFromAuthHeader

Method GetUsernameFromAuthHeader

be/src/util/webserver.cc:1117–1139  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1115}
1116
1117bool Webserver::GetUsernameFromAuthHeader(struct sq_connection* connection,
1118 struct sq_request_info* request_info, string& err_msg) {
1119 const char* authz_header = sq_get_header(connection, "Authorization");
1120 if (!authz_header) {
1121 err_msg = "no Authorization header provided.";
1122 return false;
1123 }
1124
1125 string base64;
1126 if (!TryStripPrefixString(authz_header, "Basic ", &base64)) {
1127 err_msg = "no Basic authentication provided.";
1128 return false;
1129 }
1130 string username, password;
1131 Status status = BasicAuthExtractCredentials(base64, username, password);
1132 if (!status.ok()) {
1133 err_msg = Substitute("error parsing basic authentication token from: $0, Error: $1",
1134 GetRemoteAddress(request_info).ToString(), status.GetDetail());
1135 return false;
1136 }
1137 request_info->remote_user = strdup(username.c_str());
1138 return true;
1139}
1140
1141bool Webserver::TrustedDomainCheck(const string& origin, struct sq_connection* connection,
1142 struct sq_request_info* request_info) {

Callers

nothing calls this directly

Calls 7

TryStripPrefixStringFunction · 0.85
SubstituteFunction · 0.85
GetRemoteAddressFunction · 0.85
GetDetailMethod · 0.80
okMethod · 0.45
ToStringMethod · 0.45

Tested by

no test coverage detected