Skip to content

Commit 499ccda

Browse files
committed
Restore NoOpAuthHandler and add DoNothingHandler
1 parent 3ab5937 commit 499ccda

File tree

3 files changed

+47
-23
lines changed

3 files changed

+47
-23
lines changed

cpp/src/arrow/flight/server_auth.cc

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,37 +23,50 @@ namespace arrow {
2323
namespace flight {
2424

2525
ServerAuthHandler::~ServerAuthHandler() {}
26-
// -AL- todo: write class read/write auth handler for our mock server.
27-
// I think it is needed for stable behavior.
26+
2827
NoOpAuthHandler::~NoOpAuthHandler() {}
2928
Status NoOpAuthHandler::Authenticate(const ServerCallContext& context,
3029
ServerAuthSender* outgoing,
3130
ServerAuthReader* incoming) {
31+
return Status::OK();
32+
}
33+
34+
Status NoOpAuthHandler::IsValid(const ServerCallContext& context,
35+
const std::string& token, std::string* peer_identity) {
36+
*peer_identity = "";
37+
return Status::OK();
38+
}
39+
40+
// -AL- TestServerAuthHandler should be the most similar here.
41+
DoNothingHandler::~DoNothingHandler() {}
42+
Status DoNothingHandler::Authenticate(const ServerCallContext& context,
43+
ServerAuthSender* outgoing,
44+
ServerAuthReader* incoming) {
3245
// -AL- If this approach does work, I need to create a new handler to for the mock server.
33-
ARROW_LOG(DEBUG) << "NoOpAuthHandler::Authenticate - Reading response from client";
46+
ARROW_LOG(DEBUG) << "DoNothingHandler::Authenticate - Reading response from client";
3447
std::string client_token;
3548
RETURN_NOT_OK(incoming->Read(&client_token)); // Read client's message
36-
ARROW_LOG(DEBUG) << "NoOpAuthHandler::Authenticate - client_token: " << client_token;
49+
ARROW_LOG(DEBUG) << "DoNothingHandler::Authenticate - client_token: " << client_token;
3750

3851
// -AL- do not write anything, to match real server like dbt
39-
// ARROW_LOG(DEBUG) << "NoOpAuthHandler::Authenticate - write response from server";
40-
// // Validate token, then write response
41-
// RETURN_NOT_OK(outgoing->Write("server-response")); // Write response!
42-
43-
ARROW_LOG(DEBUG) << "NoOpAuthHandler::Authenticate 1";
44-
while (incoming->Read(&client_token).ok()) {
45-
// Discard remaining messages
46-
ARROW_LOG(DEBUG) << "NoOpAuthHandler::Authenticate - drain messages from client";
47-
}
48-
ARROW_LOG(DEBUG) << "NoOpAuthHandler::Authenticate 2";
52+
ARROW_LOG(DEBUG) << "DoNothingHandler::Authenticate - write response from server";
53+
// Validate token, then write response
54+
RETURN_NOT_OK(outgoing->Write("server-response")); // Write response!
55+
56+
ARROW_LOG(DEBUG) << "DoNothingHandler::Authenticate 1";
57+
// while (incoming->Read(&client_token).ok()) {
58+
// // Discard remaining messages
59+
// ARROW_LOG(DEBUG) << "DoNothingHandler::Authenticate - drain messages from client";
60+
// }
61+
// ARROW_LOG(DEBUG) << "DoNothingHandler::Authenticate 2";
4962
return Status::OK();
5063
}
5164

52-
Status NoOpAuthHandler::IsValid(const ServerCallContext& context,
65+
Status DoNothingHandler::IsValid(const ServerCallContext& context,
5366
const std::string& token, std::string* peer_identity) {
54-
ARROW_LOG(DEBUG) << "NoOpAuthHandler::IsValid 1"; // -AL- TEMP
67+
ARROW_LOG(DEBUG) << "DoNothingHandler::IsValid 1"; // -AL- TEMP
5568
*peer_identity = "";
56-
ARROW_LOG(DEBUG) << "NoOpAuthHandler::IsValid 2"; // -AL- TEMP
69+
ARROW_LOG(DEBUG) << "DoNothingHandler::IsValid 2"; // -AL- TEMP
5770
return Status::OK();
5871
}
5972

cpp/src/arrow/flight/server_auth.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,5 +103,16 @@ class ARROW_FLIGHT_EXPORT NoOpAuthHandler : public ServerAuthHandler {
103103
std::string* peer_identity) override;
104104
};
105105

106+
/// \brief An authentication mechanism that does nothing by Alina for mock server
107+
/// TODO -AL- move to odbc tests later
108+
class ARROW_FLIGHT_EXPORT DoNothingHandler : public ServerAuthHandler {
109+
public:
110+
~DoNothingHandler() override;
111+
Status Authenticate(const ServerCallContext& context, ServerAuthSender* outgoing,
112+
ServerAuthReader* incoming) override;
113+
Status IsValid(const ServerCallContext& context, const std::string& token,
114+
std::string* peer_identity) override;
115+
};
116+
106117
} // namespace flight
107118
} // namespace arrow

cpp/src/arrow/flight/sql/odbc/odbc_impl/flight_sql_auth_method.cc

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,12 +74,12 @@ class NoOpClientAuthHandler : public ClientAuthHandler {
7474
RETURN_NOT_OK(outgoing->Write(handshake_msg));
7575
ARROW_LOG(DEBUG) << "NoOpClientAuthHandler::Authenticate 4"; // -AL- TEMP
7676

77-
// // READ the server's response -AL- code from copilot
78-
// // -AL- this is where segfault happens, so that's also shown inside grpc.
79-
// std::string response;
80-
// ARROW_LOG(DEBUG) << "NoOpClientAuthHandler::Authenticate - Reading response from server";
81-
// RETURN_NOT_OK(incoming->Read(&response));
82-
// ARROW_LOG(DEBUG) << "NoOpClientAuthHandler::Authenticate - Got response: " << response;
77+
// READ the server's response -AL- code from copilot
78+
// -AL- Authenticate func is where segfault happens, so that's also shown inside grpc.
79+
std::string response;
80+
ARROW_LOG(DEBUG) << "NoOpClientAuthHandler::Authenticate - Reading response from server";
81+
RETURN_NOT_OK(incoming->Read(&response));
82+
ARROW_LOG(DEBUG) << "NoOpClientAuthHandler::Authenticate - Got response: " << response;
8383

8484

8585
return Status::OK(); // -AL- returning OK without write doesn't resolve the issue.

0 commit comments

Comments
 (0)