1 // Licensed to the Apache Software Foundation (ASF) under one 2 // or more contributor license agreements. See the NOTICE file 3 // distributed with this work for additional information 4 // regarding copyright ownership. The ASF licenses this file 5 // to you under the Apache License, Version 2.0 (the 6 // "License"); you may not use this file except in compliance 7 // with the License. You may obtain a copy of the License at 8 // 9 // http://www.apache.org/licenses/LICENSE-2.0 10 // 11 // Unless required by applicable law or agreed to in writing, 12 // software distributed under the License is distributed on an 13 // "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 14 // KIND, either express or implied. See the License for the 15 // specific language governing permissions and limitations 16 // under the License. 17 18 #pragma once 19 20 #include <string> 21 22 #include "arrow/flight/visibility.h" 23 #include "arrow/status.h" 24 25 namespace arrow { 26 27 namespace flight { 28 29 /// \brief A reader for messages from the server during an 30 /// authentication handshake. 31 class ARROW_FLIGHT_EXPORT ClientAuthReader { 32 public: 33 virtual ~ClientAuthReader() = default; 34 virtual Status Read(std::string* response) = 0; 35 }; 36 37 /// \brief A writer for messages to the server during an 38 /// authentication handshake. 39 class ARROW_FLIGHT_EXPORT ClientAuthSender { 40 public: 41 virtual ~ClientAuthSender() = default; 42 virtual Status Write(const std::string& token) = 0; 43 }; 44 45 /// \brief An authentication implementation for a Flight service. 46 /// Authentication includes both an initial negotiation and a per-call 47 /// token validation. Implementations may choose to use either or both 48 /// mechanisms. 49 class ARROW_FLIGHT_EXPORT ClientAuthHandler { 50 public: 51 virtual ~ClientAuthHandler() = default; 52 /// \brief Authenticate the client on initial connection. The client 53 /// can send messages to/read responses from the server at any time. 54 /// \return Status OK if authenticated successfully 55 virtual Status Authenticate(ClientAuthSender* outgoing, ClientAuthReader* incoming) = 0; 56 /// \brief Get a per-call token. 57 /// \param[out] token The token to send to the server. 58 virtual Status GetToken(std::string* token) = 0; 59 }; 60 61 } // namespace flight 62 } // namespace arrow 63