MCPcopy
hub / github.com/mudler/LocalAI / get_auth_interceptors

Function get_auth_interceptors

backend/python/common/grpc_auth.py:64–78  ·  view source on GitHub ↗

Return a list of gRPC interceptors for bearer token auth. Args: aio: If True, return async-compatible interceptors for grpc.aio.server(). If False (default), return sync interceptors for grpc.server(). Returns an empty list when LOCALAI_GRPC_AUTH_TOKEN is not set.

(*, aio: bool = False)

Source from the content-addressed store, hash-verified

62
63
64def get_auth_interceptors(*, aio: bool = False):
65 """Return a list of gRPC interceptors for bearer token auth.
66
67 Args:
68 aio: If True, return async-compatible interceptors for grpc.aio.server().
69 If False (default), return sync interceptors for grpc.server().
70
71 Returns an empty list when LOCALAI_GRPC_AUTH_TOKEN is not set.
72 """
73 token = os.environ.get("LOCALAI_GRPC_AUTH_TOKEN", "")
74 if not token:
75 return []
76 if aio:
77 return [AsyncTokenAuthInterceptor(token)]
78 return [TokenAuthInterceptor(token)]

Callers 15

serveFunction · 0.90
serveFunction · 0.90
serveFunction · 0.90
serveFunction · 0.90
serveFunction · 0.90
serveFunction · 0.90
serveFunction · 0.90
serveFunction · 0.90
serveFunction · 0.90
serveFunction · 0.90
serveFunction · 0.90
serveFunction · 0.90

Calls 3

getMethod · 0.45

Tested by

no test coverage detected