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

Method SetupConnectionContext

be/src/rpc/authentication.cc:1554–1640  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1552}
1553
1554void SecureAuthProvider::SetupConnectionContext(
1555 const shared_ptr<ThriftServer::ConnectionContext>& connection_ptr,
1556 ThriftServer::TransportType underlying_transport_type,
1557 TTransport* input_transport, TTransport* output_transport) {
1558 TSocket* socket = nullptr;
1559 switch (underlying_transport_type) {
1560 case ThriftServer::BINARY: {
1561 ThriftServer::BufferedTransport* buffered_transport =
1562 down_cast<ThriftServer::BufferedTransport*>(input_transport);
1563 TSaslServerTransport* sasl_transport = down_cast<TSaslServerTransport*>(
1564 buffered_transport->getUnderlyingTransport().get());
1565 socket = down_cast<TSocket*>(sasl_transport->getUnderlyingTransport().get());
1566 // Get the username from the transport.
1567 connection_ptr->username = sasl_transport->getUsername();
1568 if (sasl_transport->getMechanismName() == KERBEROS_MECHANISM) {
1569 // Save the username as Kerberos user principal in the connection context
1570 // if the actual auth mechanism is Kerberos.
1571 connection_ptr->kerberos_user_principal = connection_ptr->username;
1572 connection_ptr->kerberos_user_short =
1573 GetShortUsernameFromKerberosPrincipal(connection_ptr->username);
1574 }
1575 break;
1576 }
1577 case ThriftServer::HTTP: {
1578 THttpServer* http_input_transport = down_cast<THttpServer*>(input_transport);
1579 THttpServer* http_output_transport = down_cast<THttpServer*>(output_transport);
1580 THttpServer::HttpCallbacks callbacks;
1581 const AuthenticationHash& hash = AuthManager::GetInstance()->GetAuthHash();
1582
1583 string saml_path;
1584 if (has_saml_) {
1585 Status parse_status = ParseSamlSpUrl(&saml_path);
1586 DCHECK(parse_status.ok());
1587 }
1588 callbacks.path_fn = std::bind(
1589 HttpPathFn, connection_ptr.get(), saml_path, std::placeholders::_1,
1590 std::placeholders::_2, std::placeholders::_3);
1591 callbacks.return_headers_fn = std::bind(ReturnHeaders, connection_ptr.get());
1592 callbacks.cookie_auth_fn =
1593 std::bind(CookieAuth, connection_ptr.get(), hash, std::placeholders::_1);
1594 callbacks.trusted_domain_check_fn = std::bind(TrustedDomainCheck,
1595 connection_ptr.get(), hash, std::placeholders::_1, std::placeholders::_2);
1596 if (has_ldap_) {
1597 callbacks.basic_auth_fn =
1598 std::bind(BasicAuth, connection_ptr.get(), hash, std::placeholders::_1);
1599 }
1600 if (!principal_.empty()) {
1601 callbacks.negotiate_auth_fn = std::bind(NegotiateAuth, connection_ptr.get(),
1602 hash, std::placeholders::_1, std::placeholders::_2);
1603 }
1604 if (has_saml_) {
1605 callbacks.init_wrapped_http_request_fn = std::bind(
1606 InitWrappedHttpRequest, connection_ptr.get());
1607 callbacks.get_saml_redirect_fn =
1608 std::bind(GetSaml2Redirect, connection_ptr.get());
1609 callbacks.validate_saml2_authn_response_fn =
1610 std::bind(ValidateSaml2AuthnResponse, connection_ptr.get(), hash);
1611 callbacks.validate_saml2_bearer_fn =

Callers 1

createContextMethod · 0.80

Calls 12

ParseSamlSpUrlFunction · 0.85
bindFunction · 0.85
SubstituteFunction · 0.85
MakeNetworkAddressFunction · 0.85
setCallbacksMethod · 0.80
getMethod · 0.65
getUsernameMethod · 0.45
getMechanismNameMethod · 0.45
okMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected