
    g#                         S SK Jr  S SKJrJr  S SKJr  S SKJr  S SK	J
r
  S SKJr  S SKJrJr   " S S	\5      r " S
 S\5      r " S S\5      r " S S\5      rg)    )Optional)APIKeyAPIKeyIn)SecurityBase)HTTPException)Request)HTTP_403_FORBIDDEN)	AnnotatedDocc                   @    \ rS rSr\S\\   S\S\\   4S j5       rSr	g)
APIKeyBase   api_key
auto_errorreturnc                 @    U (       d  U(       a  [        [        SS9eg U $ )NzNot authenticated)status_codedetail)r   r	   )r   r   s     Q/home/matz/Project1/venv/lib/python3.13/site-packages/fastapi/security/api_key.pycheck_api_keyAPIKeyBase.check_api_key   s%    # 2;N       N)
__name__
__module____qualname____firstlineno__staticmethodr   strboolr   __static_attributes__r   r   r   r   r      s1    x} $ 8C=  r   r   c                       \ rS rSrSrSSSS.S\\\" S5      4   S\\\   \" S	5      4   S
\\\   \" S5      4   S\\	\" S5      4   4S jjr
S\S\\   4S jrSrg)APIKeyQuery   a,  
API key authentication using a query parameter.

This defines the name of the query parameter that should be provided in the request
with the API key and integrates that into the OpenAPI documentation. It extracts
the key value sent in the query parameter automatically and provides it as the
dependency result. But it doesn't define how to send that API key to the client.

## Usage

Create an instance object and use that object as the dependency in `Depends()`.

The dependency result will be a string containing the key value.

## Example

```python
from fastapi import Depends, FastAPI
from fastapi.security import APIKeyQuery

app = FastAPI()

query_scheme = APIKeyQuery(name="api_key")


@app.get("/items/")
async def read_items(api_key: str = Depends(query_scheme)):
    return {"api_key": api_key}
```
NTscheme_namedescriptionr   namezQuery parameter name.r&   
                Security scheme name.

                It will be included in the generated OpenAPI (e.g. visible at `/docs`).
                r'   
                Security scheme description.

                It will be included in the generated OpenAPI (e.g. visible at `/docs`).
                r   a  
                By default, if the query parameter is not provided, `APIKeyQuery` will
                automatically cancel the request and send the client an error.

                If `auto_error` is set to `False`, when the query parameter is not
                available, instead of erroring out, the dependency result will be
                `None`.

                This is useful when you want to have optional authentication.

                It is also useful when you want to have authentication that can be
                provided in one of multiple optional ways (for example, in a query
                parameter or in an HTTP Bearer token).
                c                    [        S0 S[        R                  0DUUS.D6U l        U=(       d    U R                  R
                  U l        X@l        g Nin)r(   r'   r   )r   r   querymodel	__class__r   r&   r   selfr(   r&   r'   r   s        r   __init__APIKeyQuery.__init__7   sK    ^ $ 
X^^$
#


 'A$..*A*A$r   requestr   c                    #    UR                   R                  U R                  R                  5      nU R	                  X R
                  5      $ 7fN)query_paramsgetr/   r(   r   r   r2   r5   r   s      r   __call__APIKeyQuery.__call__n   s8     &&**4::??;!!'??;;   AAr   r/   r&   r   r   r   r   __doc__r
   r   r   r   r    r3   r   r;   r!   r   r   r   r#   r#      s    ^  & [5% '(*
5% SM	
5%" SM	
#5%6 
75%n<g <(3- <r   r#   c                       \ rS rSrSrSSSS.S\\\" S5      4   S\\\   \" S	5      4   S
\\\   \" S5      4   S\\	\" S5      4   4S jjr
S\S\\   4S jrSrg)APIKeyHeaders   a  
API key authentication using a header.

This defines the name of the header that should be provided in the request with
the API key and integrates that into the OpenAPI documentation. It extracts
the key value sent in the header automatically and provides it as the dependency
result. But it doesn't define how to send that key to the client.

## Usage

Create an instance object and use that object as the dependency in `Depends()`.

The dependency result will be a string containing the key value.

## Example

```python
from fastapi import Depends, FastAPI
from fastapi.security import APIKeyHeader

app = FastAPI()

header_scheme = APIKeyHeader(name="x-key")


@app.get("/items/")
async def read_items(key: str = Depends(header_scheme)):
    return {"key": key}
```
NTr%   r(   zHeader name.r&   r)   r'   r*   r   ax  
                By default, if the header is not provided, `APIKeyHeader` will
                automatically cancel the request and send the client an error.

                If `auto_error` is set to `False`, when the header is not available,
                instead of erroring out, the dependency result will be `None`.

                This is useful when you want to have optional authentication.

                It is also useful when you want to have authentication that can be
                provided in one of multiple optional ways (for example, in a header or
                in an HTTP Bearer token).
                c                    [        S0 S[        R                  0DUUS.D6U l        U=(       d    U R                  R
                  U l        X@l        g r,   )r   r   headerr/   r0   r   r&   r   r1   s        r   r3   APIKeyHeader.__init__   K    V $ 
X__%
#


 'A$..*A*A$r   r5   r   c                    #    UR                   R                  U R                  R                  5      nU R	                  X R
                  5      $ 7fr7   )headersr9   r/   r(   r   r   r:   s      r   r;   APIKeyHeader.__call__   6     //%%djjoo6!!'??;;r=   r>   r?   r   r   r   rB   rB   s       X  $ S1% S0011% SM	
	1% SM	
1%0 
11%f<g <(3- <r   rB   c                       \ rS rSrSrSSSS.S\\\" S5      4   S\\\   \" S	5      4   S
\\\   \" S5      4   S\\	\" S5      4   4S jjr
S\S\\   4S jrSrg)APIKeyCookie   a  
API key authentication using a cookie.

This defines the name of the cookie that should be provided in the request with
the API key and integrates that into the OpenAPI documentation. It extracts
the key value sent in the cookie automatically and provides it as the dependency
result. But it doesn't define how to set that cookie.

## Usage

Create an instance object and use that object as the dependency in `Depends()`.

The dependency result will be a string containing the key value.

## Example

```python
from fastapi import Depends, FastAPI
from fastapi.security import APIKeyCookie

app = FastAPI()

cookie_scheme = APIKeyCookie(name="session")


@app.get("/items/")
async def read_items(session: str = Depends(cookie_scheme)):
    return {"session": session}
```
NTr%   r(   zCookie name.r&   r)   r'   r*   r   ax  
                By default, if the cookie is not provided, `APIKeyCookie` will
                automatically cancel the request and send the client an error.

                If `auto_error` is set to `False`, when the cookie is not available,
                instead of erroring out, the dependency result will be `None`.

                This is useful when you want to have optional authentication.

                It is also useful when you want to have authentication that can be
                provided in one of multiple optional ways (for example, in a cookie or
                in an HTTP Bearer token).
                c                    [        S0 S[        R                  0DUUS.D6U l        U=(       d    U R                  R
                  U l        X@l        g r,   )r   r   cookier/   r0   r   r&   r   r1   s        r   r3   APIKeyCookie.__init__   rG   r   r5   r   c                    #    UR                   R                  U R                  R                  5      nU R	                  X R
                  5      $ 7fr7   )cookiesr9   r/   r(   r   r   r:   s      r   r;   APIKeyCookie.__call__  rK   r=   r>   r?   r   r   r   rN   rN      rL   r   rN   N)typingr   fastapi.openapi.modelsr   r   fastapi.security.baser   starlette.exceptionsr   starlette.requestsr   starlette.statusr	   typing_extensionsr
   r   r   r#   rB   rN   r   r   r   <module>r]      sR     3 . . & / ,	 	Y<* Y<xU<: U<pU<: U<r   