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

Class SelectiveAuthServerMiddlewareFactory

python/pyarrow/tests/test_flight.py:802–818  ·  view source on GitHub ↗

Deny access to certain methods based on a header.

Source from the content-addressed store, hash-verified

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

Callers 1

test_middleware_rejectFunction · 0.85

Calls

no outgoing calls

Tested by 1

test_middleware_rejectFunction · 0.68