lidavidm commented on a change in pull request #123:
URL: https://github.com/apache/arrow-cookbook/pull/123#discussion_r802883296
##########
File path: python/source/flight.rst
##########
@@ -387,3 +387,214 @@ stream as it arrives, instead of reading them all into a
table:
# Shutdown the server
server.shutdown()
+
+Authentication with user/password
+=================================
+
+Often, services need a way to authenticate the user and identify who
+they are. Flight provides several ways to implement authentication;
+the simplest uses a user-password scheme. At startup, the client
+authenticates itself with the server using a username and
+password. The server returns an authorization token to include on
+future requests.
+
+.. warning:: Authentication should only be used over an encrypted
+ channel, i.e. TLS should be enabled.
+
+.. note:: While the scheme is described as "`(HTTP) basic
+ authentication`_", it does not actually implement HTTP
+ authentication (RFC 7325) per se.
+
+While Flight provides some interfaces to implement such a scheme, the
+server must provide the actual implementation, as demonstrated
+below. **The implementation here is not secure and is provided as a
+minimal example only.**
+
+.. testcode::
+
+ import base64
+ import pyarrow as pa
+ import pyarrow.flight
+
+
+ class EchoServer(pa.flight.FlightServerBase):
+ """A simple server that just echoes any requests from DoAction."""
+
+ def do_action(self, context, action):
+ return [action.type.encode("utf-8"), action.body]
+
+
+ class BasicAuthServerMiddlewareFactory(pa.flight.ServerMiddlewareFactory):
+ """Middleware that implements username-password authentication."""
+
+ def __init__(self, creds):
+ self.creds = creds
Review comment:
Added a description to the docstring.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]