a c~@s&ddlZddlZddlZddlmZddlmZddlmZddl m Z m Z ddl m Z mZddlmZejdejd Ze ejeed d d ZdejeejefeejeejegefdddZGdddeZGdddZGdddZGdddZ Gddde Z!Gddde Z"dS)N) urlencode)is_async_callable) HTTPException)HTTPConnectionRequest)RedirectResponseResponse) WebSocket _CallableType)bound)connscopesreturncCs |D]}||jjvrdSqdS)NFT)authr )r r Zscopere/workspaces/shunt/resources/test-fastapi/venv/lib/python3.9/site-packages/starlette/authentication.pyhas_required_scopes r)r status_coderedirectrcs8t|tr|gnt|tjtjdfdd }|S)N)funcrcst}t|jD]&\}|jdks4|jdkr|j}qPqtdd|dkrtt j t j ddfdd }|St rtt j t j t dfdd }|Stt j t j t dfd d }|SdS) Nrequest websocketz2No "request" or "websocket" argument on function "")argskwargsrcs`|dt|kr|nd}t|ts.Jt|sH|IdHn|i|IdHdS)Nr)getlen isinstancer rclose)rrr)ridx scopes_listrrwebsocket_wrapper*s z6requires..decorator..websocket_wrappercs|dt|kr|nd}t|ts.Jt|s|durrtdt|ji}dj| |d}t |ddSt d|i|IdHSNrnextz{redirect_path}?{orig_request})Z redirect_pathZ orig_requesti/)urlr)r rrrrrrstrr%formatZurl_forrrrrrZorig_request_qparamZnext_urlrr rr!rrr async_wrapper<s    z2requires..decorator..async_wrappercs|dt|kr|nd}t|ts.Jt|s|durrtdt|ji}dj| |d}t |ddSt d|i|Sr#r&r)r*rr sync_wrapperRs    z1requires..decorator..sync_wrapper) inspect signature enumerate parametersvaluesname Exception functoolswrapstypingAnyrr)rsigZ parametertype_r"r+r,rr!r)rr r decorators.   $zrequires..decorator)rr'listr6Callable)r rrr;rr:rrequiressGr>c@s eZdZdS)AuthenticationErrorN)__name__ __module__ __qualname__rrrrr?gsr?c@s(eZdZeejejddddZdS)AuthenticationBackend)AuthCredentialsBaseUser)r rcs tdSNNotImplementedError)selfr rrr authenticatelsz"AuthenticationBackend.authenticateN)r@rArBrr6OptionalTuplerJrrrrrCksrCc@s(eZdZdejejedddZdS)rDN)r cCs|dur gnt||_dSrF)r<r )rIr rrr__init__sszAuthCredentials.__init__)N)r@rArBr6rKSequencer'rMrrrrrDrsrDc@sBeZdZeedddZeedddZeedddZdS) rErcCs tdSrFrGrIrrris_authenticatedxszBaseUser.is_authenticatedcCs tdSrFrGrPrrr display_name|szBaseUser.display_namecCs tdSrFrGrPrrridentityszBaseUser.identityN) r@rArBpropertyboolrQr'rRrSrrrrrEws rEc@s@eZdZeddddZeedddZeeddd ZdS) SimpleUserN)usernamercCs ||_dSrFrW)rIrWrrrrMszSimpleUser.__init__rOcCsdS)NTrrPrrrrQszSimpleUser.is_authenticatedcCs|jSrFrXrPrrrrRszSimpleUser.display_name) r@rArBr'rMrTrUrQrRrrrrrVs rVc@s0eZdZeedddZeedddZdS)UnauthenticatedUserrOcCsdS)NFrrPrrrrQsz$UnauthenticatedUser.is_authenticatedcCsdS)NrrPrrrrRsz UnauthenticatedUser.display_nameN)r@rArBrTrUrQr'rRrrrrrYsrY)rN)#r4r-r6 urllib.parserZstarlette._utilsrZstarlette.exceptionsrZstarlette.requestsrrZstarlette.responsesrrZstarlette.websocketsr TypeVarr=r rNr'rUrUnionintrKr>r3r?rCrDrErVrYrrrrs0      Q