| 761 | } |
| 762 | |
| 763 | bool BasicAuth(ThriftServer::ConnectionContext* connection_context, |
| 764 | const AuthenticationHash& hash, const string& base64) { |
| 765 | string username, password; |
| 766 | Status status = BasicAuthExtractCredentials(base64, username, password); |
| 767 | if (!status.ok()) { |
| 768 | LOG(ERROR) << "Error parsing basic authentication token from: " |
| 769 | << TNetworkAddressToString(connection_context->network_address) |
| 770 | << " Error: " << status; |
| 771 | connection_context->return_headers.push_back("WWW-Authenticate: Basic"); |
| 772 | return false; |
| 773 | } |
| 774 | bool ret = DoLdapCheck(username.c_str(), password.c_str(), password.length()); |
| 775 | if (ret) { |
| 776 | // Authenication was successful, so set the username on the connection. |
| 777 | connection_context->username = username; |
| 778 | // Create a cookie to return. |
| 779 | connection_context->return_headers.push_back( |
| 780 | Substitute("Set-Cookie: $0", |
| 781 | GenerateCookie(username, hash, HTTP_AUTH_MECH_LDAP))); |
| 782 | if (!FLAGS_test_cookie.empty()) { |
| 783 | connection_context->return_headers.push_back( |
| 784 | Substitute("Set-Cookie: $0", FLAGS_test_cookie)); |
| 785 | } |
| 786 | return true; |
| 787 | } |
| 788 | connection_context->return_headers.push_back("WWW-Authenticate: Basic"); |
| 789 | return false; |
| 790 | } |
| 791 | |
| 792 | bool JWTTokenAuth(ThriftServer::ConnectionContext* connection_context, |
| 793 | const AuthenticationHash& hash, const string& token) { |
nothing calls this directly
no test coverage detected