MCPcopy
hub / github.com/apache/caldera / authentication_required_middleware_factory

Function authentication_required_middleware_factory

app/api/v2/security.py:55–69  ·  view source on GitHub ↗

Enforce authentication on every endpoint within an web application. Note: Any endpoint handler can opt-out of authentication using the @authentication_exempt decorator.

(auth_svc)

Source from the content-addressed store, hash-verified

53
54
55def authentication_required_middleware_factory(auth_svc):
56 """Enforce authentication on every endpoint within an web application.
57
58 Note:
59 Any endpoint handler can opt-out of authentication using the
60 @authentication_exempt decorator.
61 """
62 @web.middleware
63 async def authentication_required_middleware(request, handler):
64 if is_handler_authentication_exempt(handler):
65 return await handler(request)
66 if not await auth_svc.is_request_authenticated(request):
67 raise web.HTTPUnauthorized()
68 return await handler(request)
69 return authentication_required_middleware
70
71
72@web.middleware

Callers 3

make_appFunction · 0.90
knowledge_webappFunction · 0.90
make_appFunction · 0.85

Calls

no outgoing calls

Tested by 2

make_appFunction · 0.72
knowledge_webappFunction · 0.72