| 1115 | } |
| 1116 | |
| 1117 | bool 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 | |
| 1141 | bool Webserver::TrustedDomainCheck(const string& origin, struct sq_connection* connection, |
| 1142 | struct sq_request_info* request_info) { |
nothing calls this directly
no test coverage detected