Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion cpp/src/arrow/flight/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,6 @@ set(ARROW_FLIGHT_SRCS
serialization_internal.cc
server.cc
server_auth.cc
server_middleware.cc
server_tracing_middleware.cc
transport.cc
transport_server.cc
Expand Down
20 changes: 1 addition & 19 deletions cpp/src/arrow/flight/server_auth.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,25 +61,7 @@ class ARROW_FLIGHT_EXPORT ServerAuthHandler {
/// \param[in] incoming The reader for messages from the client.
/// \return Status OK if this authentication is succeeded.
virtual Status Authenticate(const ServerCallContext& context,
ServerAuthSender* outgoing, ServerAuthReader* incoming) {
// TODO: We can make this pure virtual function when we remove
// the deprecated version.
ARROW_SUPPRESS_DEPRECATION_WARNING
return Authenticate(outgoing, incoming);
ARROW_UNSUPPRESS_DEPRECATION_WARNING
}
/// \brief Authenticate the client on initial connection. The server
/// can send and read responses from the client at any time.
/// \param[in] outgoing The writer for messages to the client.
/// \param[in] incoming The reader for messages from the client.
/// \return Status OK if this authentication is succeeded.
/// \deprecated Deprecated in 13.0.0. Implement the Authentication()
/// with ServerCallContext version instead.
ARROW_DEPRECATED("Deprecated in 13.0.0. Use ServerCallContext overload instead.")
virtual Status Authenticate(ServerAuthSender* outgoing, ServerAuthReader* incoming) {
return Status::NotImplemented(typeid(this).name(),
"::Authenticate() isn't implemented");
}
ServerAuthSender* outgoing, ServerAuthReader* incoming) = 0;
/// \brief Validate a per-call client token.
/// \param[in] context The call context.
/// \param[in] token The client token. May be the empty string if
Expand Down
35 changes: 0 additions & 35 deletions cpp/src/arrow/flight/server_middleware.cc

This file was deleted.

24 changes: 1 addition & 23 deletions cpp/src/arrow/flight/server_middleware.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,29 +75,7 @@ class ARROW_FLIGHT_EXPORT ServerMiddlewareFactory {
/// their CallCompleted callback called. Other middleware
/// factories will not be called.
virtual Status StartCall(const CallInfo& info, const ServerCallContext& context,
std::shared_ptr<ServerMiddleware>* middleware);

/// \brief A callback for the start of a new call.
///
/// Return a non-OK status to reject the call with the given status.
///
/// \param info Information about the call.
/// \param incoming_headers Headers sent by the client for this call.
/// Do not retain a reference to this object.
/// \param[out] middleware The middleware instance for this call. If
/// null, no middleware will be added to this call instance from
/// this factory.
/// \return Status A non-OK status will reject the call with the
/// given status. Middleware previously in the chain will have
/// their CallCompleted callback called. Other middleware
/// factories will not be called.
/// \deprecated Deprecated in 13.0.0. Implement the StartCall()
/// with ServerCallContext version instead.
ARROW_DEPRECATED("Deprecated in 13.0.0. Use ServerCallContext overload instead.")
virtual Status StartCall(const CallInfo& info, const CallHeaders& incoming_headers,
std::shared_ptr<ServerMiddleware>* middleware) {
return Status::NotImplemented(typeid(this).name(), "::StartCall() isn't implemented");
}
std::shared_ptr<ServerMiddleware>* middleware) = 0;
};

} // namespace flight
Expand Down
11 changes: 6 additions & 5 deletions cpp/src/arrow/flight/sql/server_session_middleware.cc
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include <mutex>

#include "arrow/flight/server.h"
#include "arrow/flight/sql/server_session_middleware.h"
#include "arrow/flight/sql/server_session_middleware_factory.h"

Expand Down Expand Up @@ -134,12 +135,12 @@ ServerSessionMiddlewareFactory::ParseCookieString(const std::string_view& s) {
}

Status ServerSessionMiddlewareFactory::StartCall(
const CallInfo&, const CallHeaders& incoming_headers,
const CallInfo&, const ServerCallContext& context,
std::shared_ptr<ServerMiddleware>* middleware) {
std::string session_id;

const std::pair<CallHeaders::const_iterator, CallHeaders::const_iterator>&
headers_it_pr = incoming_headers.equal_range("cookie");
headers_it_pr = context.incoming_headers().equal_range("cookie");
for (auto itr = headers_it_pr.first; itr != headers_it_pr.second; ++itr) {
const std::string_view& cookie_header = itr->second;
const std::vector<std::pair<std::string, std::string>> cookies =
Expand All @@ -158,16 +159,16 @@ Status ServerSessionMiddlewareFactory::StartCall(
// No cookie was found
// Temporary workaround until middleware handling fixed
auto [id, s] = CreateNewSession();
*middleware = std::make_shared<ServerSessionMiddlewareImpl>(this, incoming_headers,
std::move(s), id, false);
*middleware = std::make_shared<ServerSessionMiddlewareImpl>(
this, context.incoming_headers(), std::move(s), id, false);
} else {
const std::shared_lock<std::shared_mutex> l(session_store_lock_);
if (auto it = session_store_.find(session_id); it == session_store_.end()) {
return Status::Invalid("Invalid or expired ", kSessionCookieName, " cookie.");
} else {
auto session = it->second;
*middleware = std::make_shared<ServerSessionMiddlewareImpl>(
this, incoming_headers, std::move(session), session_id);
this, context.incoming_headers(), std::move(session), session_id);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class ARROW_FLIGHT_SQL_EXPORT ServerSessionMiddlewareFactory
public:
explicit ServerSessionMiddlewareFactory(std::function<std::string()> id_gen)
: id_generator_(id_gen) {}
Status StartCall(const CallInfo&, const CallHeaders& incoming_headers,
Status StartCall(const CallInfo&, const ServerCallContext& context,
std::shared_ptr<ServerMiddleware>* middleware) override;

/// \brief Get a new, empty session option map and its id key.
Expand Down
9 changes: 5 additions & 4 deletions python/pyarrow/src/arrow/python/flight.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ PyServerAuthHandler::PyServerAuthHandler(PyObject* handler,
handler_.reset(handler);
}

Status PyServerAuthHandler::Authenticate(arrow::flight::ServerAuthSender* outgoing,
Status PyServerAuthHandler::Authenticate(const arrow::flight::ServerCallContext& context,
arrow::flight::ServerAuthSender* outgoing,
Comment thread
AlenkaF marked this conversation as resolved.
Resolved
arrow::flight::ServerAuthReader* incoming) {
return SafeCallIntoPython([=] {
const Status status = vtable_.authenticate(handler_.obj(), outgoing, incoming);
Expand Down Expand Up @@ -267,11 +268,11 @@ PyServerMiddlewareFactory::PyServerMiddlewareFactory(PyObject* factory,
}

Status PyServerMiddlewareFactory::StartCall(
const arrow::flight::CallInfo& info,
const arrow::flight::CallHeaders& incoming_headers,
const arrow::flight::CallInfo& info, const arrow::flight::ServerCallContext& context,
std::shared_ptr<arrow::flight::ServerMiddleware>* middleware) {
return SafeCallIntoPython([&] {
const Status status = start_call_(factory_.obj(), info, incoming_headers, middleware);
const Status status =
start_call_(factory_.obj(), info, context.incoming_headers(), middleware);
RETURN_NOT_OK(CheckPyError());
return status;
});
Expand Down
5 changes: 3 additions & 2 deletions python/pyarrow/src/arrow/python/flight.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,8 @@ class ARROW_PYFLIGHT_EXPORT PyServerAuthHandler
public:
explicit PyServerAuthHandler(PyObject* handler,
const PyServerAuthHandlerVtable& vtable);
Status Authenticate(arrow::flight::ServerAuthSender* outgoing,
Status Authenticate(const arrow::flight::ServerCallContext& context,
arrow::flight::ServerAuthSender* outgoing,
arrow::flight::ServerAuthReader* incoming) override;
Status IsValid(const std::string& token, std::string* peer_identity) override;

Expand Down Expand Up @@ -225,7 +226,7 @@ class ARROW_PYFLIGHT_EXPORT PyServerMiddlewareFactory
explicit PyServerMiddlewareFactory(PyObject* factory, StartCallCallback start_call);

Status StartCall(const arrow::flight::CallInfo& info,
const arrow::flight::CallHeaders& incoming_headers,
const arrow::flight::ServerCallContext& context,
std::shared_ptr<arrow::flight::ServerMiddleware>* middleware) override;

private:
Expand Down