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

Class SelectiveAuthServerMiddlewareFactory

python/pyarrow/tests/test_flight.py:804–820  ·  view source on GitHub ↗

Deny access to certain methods based on a header.

Source from the content-addressed store, hash-verified

802
803
804class SelectiveAuthServerMiddlewareFactory(ServerMiddlewareFactory):
805 """Deny access to certain methods based on a header."""
806
807 def start_call(self, info, headers):
808 if info.method == flight.FlightMethod.LIST_ACTIONS:
809 # No auth needed
810 return
811
812 token = headers.get("x-auth-token")
813 if not token:
814 raise flight.FlightUnauthenticatedError("No token")
815
816 token = token[0]
817 if token != "password":
818 raise flight.FlightUnauthenticatedError("Invalid token")
819
820 return HeaderServerMiddleware(token)
821
822
823class SelectiveAuthClientMiddlewareFactory(ClientMiddlewareFactory):

Callers 1

test_middleware_rejectFunction · 0.85

Calls

no outgoing calls

Tested by 1

test_middleware_rejectFunction · 0.68