Skip to content

Commit 618ef50

Browse files
authored
GH-45922: [C++][Flight] Remove deprecated Authenticate and StartCall (#45932)
### Rationale for this change [Authenticate](https://github.com/apache/arrow/blob/c124bb55d993daca93742ce896869ab3101dccbb/cpp/src/arrow/flight/server_auth.h#L76) and [StartCall](https://github.com/apache/arrow/blob/c124bb55d993daca93742ce896869ab3101dccbb/cpp/src/arrow/flight/server_middleware.h#L94) have been deprecated in 13.0.0 and can now be removed. ### What changes are included in this PR? `ServerAuthHandler.Authenticate` and `ServerMiddlewareFactory.StartCall` versions without `ServerCallContext` are removed. ### Are these changes tested? Existing tests should pass. ### Are there any user-facing changes? Deprecated Flight functionality is removed. * GitHub Issue: #45922 Authored-by: AlenkaF <frim.alenka@gmail.com> Signed-off-by: AlenkaF <frim.alenka@gmail.com>
1 parent 7e3b991 commit 618ef50

File tree

8 files changed

+17
-90
lines changed

8 files changed

+17
-90
lines changed

cpp/src/arrow/flight/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,6 @@ set(ARROW_FLIGHT_SRCS
146146
serialization_internal.cc
147147
server.cc
148148
server_auth.cc
149-
server_middleware.cc
150149
server_tracing_middleware.cc
151150
transport.cc
152151
transport_server.cc

cpp/src/arrow/flight/server_auth.h

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -61,25 +61,7 @@ class ARROW_FLIGHT_EXPORT ServerAuthHandler {
6161
/// \param[in] incoming The reader for messages from the client.
6262
/// \return Status OK if this authentication is succeeded.
6363
virtual Status Authenticate(const ServerCallContext& context,
64-
ServerAuthSender* outgoing, ServerAuthReader* incoming) {
65-
// TODO: We can make this pure virtual function when we remove
66-
// the deprecated version.
67-
ARROW_SUPPRESS_DEPRECATION_WARNING
68-
return Authenticate(outgoing, incoming);
69-
ARROW_UNSUPPRESS_DEPRECATION_WARNING
70-
}
71-
/// \brief Authenticate the client on initial connection. The server
72-
/// can send and read responses from the client at any time.
73-
/// \param[in] outgoing The writer for messages to the client.
74-
/// \param[in] incoming The reader for messages from the client.
75-
/// \return Status OK if this authentication is succeeded.
76-
/// \deprecated Deprecated in 13.0.0. Implement the Authentication()
77-
/// with ServerCallContext version instead.
78-
ARROW_DEPRECATED("Deprecated in 13.0.0. Use ServerCallContext overload instead.")
79-
virtual Status Authenticate(ServerAuthSender* outgoing, ServerAuthReader* incoming) {
80-
return Status::NotImplemented(typeid(this).name(),
81-
"::Authenticate() isn't implemented");
82-
}
64+
ServerAuthSender* outgoing, ServerAuthReader* incoming) = 0;
8365
/// \brief Validate a per-call client token.
8466
/// \param[in] context The call context.
8567
/// \param[in] token The client token. May be the empty string if

cpp/src/arrow/flight/server_middleware.cc

Lines changed: 0 additions & 35 deletions
This file was deleted.

cpp/src/arrow/flight/server_middleware.h

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -75,29 +75,7 @@ class ARROW_FLIGHT_EXPORT ServerMiddlewareFactory {
7575
/// their CallCompleted callback called. Other middleware
7676
/// factories will not be called.
7777
virtual Status StartCall(const CallInfo& info, const ServerCallContext& context,
78-
std::shared_ptr<ServerMiddleware>* middleware);
79-
80-
/// \brief A callback for the start of a new call.
81-
///
82-
/// Return a non-OK status to reject the call with the given status.
83-
///
84-
/// \param info Information about the call.
85-
/// \param incoming_headers Headers sent by the client for this call.
86-
/// Do not retain a reference to this object.
87-
/// \param[out] middleware The middleware instance for this call. If
88-
/// null, no middleware will be added to this call instance from
89-
/// this factory.
90-
/// \return Status A non-OK status will reject the call with the
91-
/// given status. Middleware previously in the chain will have
92-
/// their CallCompleted callback called. Other middleware
93-
/// factories will not be called.
94-
/// \deprecated Deprecated in 13.0.0. Implement the StartCall()
95-
/// with ServerCallContext version instead.
96-
ARROW_DEPRECATED("Deprecated in 13.0.0. Use ServerCallContext overload instead.")
97-
virtual Status StartCall(const CallInfo& info, const CallHeaders& incoming_headers,
98-
std::shared_ptr<ServerMiddleware>* middleware) {
99-
return Status::NotImplemented(typeid(this).name(), "::StartCall() isn't implemented");
100-
}
78+
std::shared_ptr<ServerMiddleware>* middleware) = 0;
10179
};
10280

10381
} // namespace flight

cpp/src/arrow/flight/sql/server_session_middleware.cc

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
#include <mutex>
1919

20+
#include "arrow/flight/server.h"
2021
#include "arrow/flight/sql/server_session_middleware.h"
2122
#include "arrow/flight/sql/server_session_middleware_factory.h"
2223

@@ -134,12 +135,12 @@ ServerSessionMiddlewareFactory::ParseCookieString(const std::string_view& s) {
134135
}
135136

136137
Status ServerSessionMiddlewareFactory::StartCall(
137-
const CallInfo&, const CallHeaders& incoming_headers,
138+
const CallInfo&, const ServerCallContext& context,
138139
std::shared_ptr<ServerMiddleware>* middleware) {
139140
std::string session_id;
140141

141142
const std::pair<CallHeaders::const_iterator, CallHeaders::const_iterator>&
142-
headers_it_pr = incoming_headers.equal_range("cookie");
143+
headers_it_pr = context.incoming_headers().equal_range("cookie");
143144
for (auto itr = headers_it_pr.first; itr != headers_it_pr.second; ++itr) {
144145
const std::string_view& cookie_header = itr->second;
145146
const std::vector<std::pair<std::string, std::string>> cookies =
@@ -158,16 +159,16 @@ Status ServerSessionMiddlewareFactory::StartCall(
158159
// No cookie was found
159160
// Temporary workaround until middleware handling fixed
160161
auto [id, s] = CreateNewSession();
161-
*middleware = std::make_shared<ServerSessionMiddlewareImpl>(this, incoming_headers,
162-
std::move(s), id, false);
162+
*middleware = std::make_shared<ServerSessionMiddlewareImpl>(
163+
this, context.incoming_headers(), std::move(s), id, false);
163164
} else {
164165
const std::shared_lock<std::shared_mutex> l(session_store_lock_);
165166
if (auto it = session_store_.find(session_id); it == session_store_.end()) {
166167
return Status::Invalid("Invalid or expired ", kSessionCookieName, " cookie.");
167168
} else {
168169
auto session = it->second;
169170
*middleware = std::make_shared<ServerSessionMiddlewareImpl>(
170-
this, incoming_headers, std::move(session), session_id);
171+
this, context.incoming_headers(), std::move(session), session_id);
171172
}
172173
}
173174

cpp/src/arrow/flight/sql/server_session_middleware_factory.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class ARROW_FLIGHT_SQL_EXPORT ServerSessionMiddlewareFactory
4646
public:
4747
explicit ServerSessionMiddlewareFactory(std::function<std::string()> id_gen)
4848
: id_generator_(id_gen) {}
49-
Status StartCall(const CallInfo&, const CallHeaders& incoming_headers,
49+
Status StartCall(const CallInfo&, const ServerCallContext& context,
5050
std::shared_ptr<ServerMiddleware>* middleware) override;
5151

5252
/// \brief Get a new, empty session option map and its id key.

python/pyarrow/src/arrow/python/flight.cc

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ PyServerAuthHandler::PyServerAuthHandler(PyObject* handler,
3737
handler_.reset(handler);
3838
}
3939

40-
Status PyServerAuthHandler::Authenticate(arrow::flight::ServerAuthSender* outgoing,
40+
Status PyServerAuthHandler::Authenticate(const arrow::flight::ServerCallContext& context,
41+
arrow::flight::ServerAuthSender* outgoing,
4142
arrow::flight::ServerAuthReader* incoming) {
4243
return SafeCallIntoPython([=] {
4344
const Status status = vtable_.authenticate(handler_.obj(), outgoing, incoming);
@@ -267,11 +268,11 @@ PyServerMiddlewareFactory::PyServerMiddlewareFactory(PyObject* factory,
267268
}
268269

269270
Status PyServerMiddlewareFactory::StartCall(
270-
const arrow::flight::CallInfo& info,
271-
const arrow::flight::CallHeaders& incoming_headers,
271+
const arrow::flight::CallInfo& info, const arrow::flight::ServerCallContext& context,
272272
std::shared_ptr<arrow::flight::ServerMiddleware>* middleware) {
273273
return SafeCallIntoPython([&] {
274-
const Status status = start_call_(factory_.obj(), info, incoming_headers, middleware);
274+
const Status status =
275+
start_call_(factory_.obj(), info, context.incoming_headers(), middleware);
275276
RETURN_NOT_OK(CheckPyError());
276277
return status;
277278
});

python/pyarrow/src/arrow/python/flight.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,8 @@ class ARROW_PYFLIGHT_EXPORT PyServerAuthHandler
114114
public:
115115
explicit PyServerAuthHandler(PyObject* handler,
116116
const PyServerAuthHandlerVtable& vtable);
117-
Status Authenticate(arrow::flight::ServerAuthSender* outgoing,
117+
Status Authenticate(const arrow::flight::ServerCallContext& context,
118+
arrow::flight::ServerAuthSender* outgoing,
118119
arrow::flight::ServerAuthReader* incoming) override;
119120
Status IsValid(const std::string& token, std::string* peer_identity) override;
120121

@@ -225,7 +226,7 @@ class ARROW_PYFLIGHT_EXPORT PyServerMiddlewareFactory
225226
explicit PyServerMiddlewareFactory(PyObject* factory, StartCallCallback start_call);
226227

227228
Status StartCall(const arrow::flight::CallInfo& info,
228-
const arrow::flight::CallHeaders& incoming_headers,
229+
const arrow::flight::ServerCallContext& context,
229230
std::shared_ptr<arrow::flight::ServerMiddleware>* middleware) override;
230231

231232
private:

0 commit comments

Comments
 (0)