| 689 | } |
| 690 | |
| 691 | static bool GetUsernameFromBasicAuthHeader( |
| 692 | ThriftServer::ConnectionContext* connection_context, string auth_header) { |
| 693 | string stripped_basic_auth_token; |
| 694 | StripWhiteSpace(&auth_header); |
| 695 | bool got_basic_auth = |
| 696 | TryStripPrefixString(auth_header, "Basic ", &stripped_basic_auth_token); |
| 697 | string basic_auth_token = got_basic_auth ? move(stripped_basic_auth_token) : ""; |
| 698 | string username, password; |
| 699 | Status status = BasicAuthExtractCredentials(basic_auth_token, username, password); |
| 700 | if (!status.ok()) { |
| 701 | LOG(ERROR) << "Error parsing basic authentication token from: " |
| 702 | << TNetworkAddressToString(connection_context->network_address) |
| 703 | << " Error: " << status; |
| 704 | return false; |
| 705 | } |
| 706 | connection_context->username = username; |
| 707 | return true; |
| 708 | } |
| 709 | |
| 710 | bool SetOrigin( |
| 711 | ThriftServer::ConnectionContext* connection_context, const std::string& origin) { |
no test coverage detected