MCPcopy Create free account
hub / github.com/apache/arrow / HttpBasicServerAuthHandler

Class HttpBasicServerAuthHandler

python/pyarrow/tests/test_flight.py:534–555  ·  view source on GitHub ↗

An example implementation of HTTP basic authentication.

Source from the content-addressed store, hash-verified

532
533
534class HttpBasicServerAuthHandler(ServerAuthHandler):
535 """An example implementation of HTTP basic authentication."""
536
537 def __init__(self, creds):
538 super().__init__()
539 self.creds = creds
540
541 def authenticate(self, outgoing, incoming):
542 buf = incoming.read()
543 auth = flight.BasicAuth.deserialize(buf)
544 if auth.username not in self.creds:
545 raise flight.FlightUnauthenticatedError("unknown user")
546 if self.creds[auth.username] != auth.password:
547 raise flight.FlightUnauthenticatedError("wrong password")
548 outgoing.write(tobytes(auth.username))
549
550 def is_valid(self, token):
551 if not token:
552 raise flight.FlightUnauthenticatedError("token not provided")
553 if token not in self.creds:
554 raise flight.FlightUnauthenticatedError("unknown user")
555 return token
556
557
558class HttpBasicClientAuthHandler(ClientAuthHandler):

Callers 1

test_flight.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected