a c@sfddlZddlmZmZmZmZddlmZddlm Z m Z ddl m Z m Z mZmZGdddZdS)N)AuthCredentialsAuthenticationBackendAuthenticationErrorUnauthenticatedUser)HTTPConnection)PlainTextResponseResponse)ASGIAppReceiveScopeSendc@s`eZdZd eeejejee ge fddddZ e e eddddZeeee dd d ZdS) AuthenticationMiddlewareN)appbackendon_errorreturncCs$||_||_|dur|n|j|_dS)N)rrdefault_on_errorr)selfrrrrp/workspaces/shunt/resources/test-fastapi/venv/lib/python3.9/site-packages/starlette/middleware/authentication.py__init__sz!AuthenticationMiddleware.__init__)scopereceivesendrc s|ddvr$||||IdHdSt|}z|j|IdH}Wnfty}zN|||}|ddkr|dddIdHn||||IdHWYd}~dSd}~00|durttf}|\|d<|d<||||IdHdS) Ntype)http websocketrzwebsocket.closei)rcodeauthuser)rrrZ authenticaterrrr)rrrrconnZ auth_resultexcresponserrr__call__s     z!AuthenticationMiddleware.__call__)r r!rcCstt|ddS)Ni) status_code)rstr)r r!rrrr2sz)AuthenticationMiddleware.default_on_error)N)__name__ __module__ __qualname__r rtypingOptionalCallablerrrrr r r r# staticmethod Exceptionrrrrrr s r )r)Zstarlette.authenticationrrrrZstarlette.requestsrZstarlette.responsesrrZstarlette.typesr r r r r rrrrs