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

Class HttpBasicServerAuthHandler

python/pyarrow/tests/test_flight.py:536–557  ·  view source on GitHub ↗

An example implementation of HTTP basic authentication.

Source from the content-addressed store, hash-verified

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

Callers 1

test_flight.pyFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected