a cL@sddlZddlmZddlmZddlmZddlmZ ddlm Z ddl m Z ddlmZdd lmZdd lmZdd lmZmZGd d d eZGdddeZGddde ZGdddeZGdddeZ GdddeZdS)N) b64decode)Optional) HTTPException)HTTPBase) HTTPBearer) SecurityBase)get_authorization_scheme_param) BaseModel)Request)HTTP_401_UNAUTHORIZEDHTTP_403_FORBIDDENc@seZdZUeed<eed<dS)HTTPBasicCredentialsusernamepasswordN__name__ __module__ __qualname__str__annotations__rrb/workspaces/shunt/resources/test-fastapi/venv/lib/python3.9/site-packages/fastapi/security/http.pyr s r c@seZdZUeed<eed<dS)HTTPAuthorizationCredentialsscheme credentialsNrrrrrrs rc@sFeZdZddddeeeeeedddZeeeddd Z dS) rNT scheme_name description auto_error)rrrrcCs&t||d|_|p|jj|_||_dS)Nrr HTTPBaseModelmodel __class__rrr)selfrrrrrrr__init__szHTTPBase.__init__requestreturncsH|jd}t|\}}|r$|r$|s<|jr8ttddndSt||dS)N AuthorizationNot authenticated status_codedetailrr)headersgetrrrr rr$r' authorizationrrrrr__call__&s   zHTTPBase.__call__) rrrrrboolr%r rr3rrrrrs rc@sLeZdZdddddeeeeeeedddZeeedddZ dS) HTTPBasicNT)rrealmrrcCs,td|d|_|p|jj|_||_||_dS)Nbasicr)r!r"r#rrr6r)r$rr6rrrrrr%6szHTTPBasic.__init__r&c s|jd}t|\}}|jr2dd|jdi}nddi}ttd|d}|rX|dkrr|jrnttd |dndSzt| d }Wnt t t j fy|Yn0|d \}} } | s|t|| d S) Nr)zWWW-Authenticatez Basic realm=""ZBasic"Invalid authentication credentials)r,r-r/r7r*ascii:)rr)r/r0rr6rr lowerrrdecode ValueErrorUnicodeDecodeErrorbinasciiError partitionr ) r$r'r2rparamZunauthorized_headersZinvalid_user_credentials_excdatar separatorrrrrr3Cs4   zHTTPBasic.__call__) rrrrrr4r%r r r3rrrrr55s r5c@sLeZdZdddddeeeeeeedddZeeedddZ dS) rNT) bearerFormatrrrcCs&t||d|_|p|jj|_||_dS)N)rFr)HTTPBearerModelr"r#rrr)r$rFrrrrrrr%eszHTTPBearer.__init__r&csl|jd}t|\}}|r$|r$|s<|jr8ttddndS|dkr`|jr\ttddndSt||dS)Nr)r*r+Zbearerr9r.r/r0rrrr r<rr1rrrr3qs     zHTTPBearer.__call__ rrrrrr4r%r rr3rrrrrds rc@sDeZdZddddeeeeedddZeeedddZ dS) HTTPDigestNTrcCs&td|d|_|p|jj|_||_dS)Ndigestrr )r$rrrrrrr%szHTTPDigest.__init__r&cs`|jd}t|\}}|r$|r$|s<|jr8ttddndS|dkrTttddt||dS)Nr)r*r+rKr9r.rHr1rrrr3s    zHTTPDigest.__call__rIrrrrrJs rJ)r@base64rtypingrZfastapi.exceptionsrZfastapi.openapi.modelsrr!rrGZfastapi.security.baserZfastapi.security.utilsrZpydanticr Zstarlette.requestsr Zstarlette.statusr r r rr5rJrrrrs          /$