| 663 | } |
| 664 | |
| 665 | bool CookieAuth(ThriftServer::ConnectionContext* connection_context, |
| 666 | const AuthenticationHash& hash, const std::string& cookie_header) { |
| 667 | string username; |
| 668 | string authMech; |
| 669 | Status cookie_status = AuthenticateCookie(hash, cookie_header, &username, &authMech); |
| 670 | if (cookie_status.ok()) { |
| 671 | connection_context->username = username; |
| 672 | if (authMech == HTTP_AUTH_MECH_SPNEGO) { |
| 673 | connection_context->kerberos_user_principal = username; |
| 674 | connection_context->kerberos_user_short = |
| 675 | GetShortUsernameFromKerberosPrincipal(username); |
| 676 | VLOG(2) << "Connection authenticated with " |
| 677 | << "short username \"" << connection_context->kerberos_user_short << "\" " |
| 678 | << "parsed from principal \"" << username << "\" "; |
| 679 | } |
| 680 | return true; |
| 681 | } |
| 682 | |
| 683 | LOG(INFO) << "Invalid cookie provided: " << cookie_header |
| 684 | << " from: " << TNetworkAddressToString(connection_context->network_address) |
| 685 | << ": " << cookie_status.GetDetail(); |
| 686 | connection_context->return_headers.push_back( |
| 687 | Substitute("Set-Cookie: $0", GetDeleteCookie())); |
| 688 | return false; |
| 689 | } |
| 690 | |
| 691 | static bool GetUsernameFromBasicAuthHeader( |
| 692 | ThriftServer::ConnectionContext* connection_context, string auth_header) { |
nothing calls this directly
no test coverage detected