Home / File/ http.py — fastapi Source File

http.py — fastapi Source File

Architecture documentation for http.py, a python file in the fastapi codebase. 16 imports, 4 dependents.

File python Security Schemes 16 imports 4 dependents 6 classes

Entity Profile

Dependency Diagram

graph LR
  96278b4c_a391_681f_b974_563be8af72ce["http.py"]
  8d868437_bc50_d286_af3a_6f7dff3c18d6["binascii"]
  96278b4c_a391_681f_b974_563be8af72ce --> 8d868437_bc50_d286_af3a_6f7dff3c18d6
  734b7bd2_2a77_3a17_a6c0_ce892aafd817["base64"]
  96278b4c_a391_681f_b974_563be8af72ce --> 734b7bd2_2a77_3a17_a6c0_ce892aafd817
  0dda2280_3359_8460_301c_e98c77e78185["typing"]
  96278b4c_a391_681f_b974_563be8af72ce --> 0dda2280_3359_8460_301c_e98c77e78185
  5efacb44_5373_ceb9_9579_6e6603820488["annotated_doc"]
  96278b4c_a391_681f_b974_563be8af72ce --> 5efacb44_5373_ceb9_9579_6e6603820488
  01c652c5_d85c_f45e_848e_412c94ea4172["exceptions.py"]
  96278b4c_a391_681f_b974_563be8af72ce --> 01c652c5_d85c_f45e_848e_412c94ea4172
  53e07af2_3e5c_ea1f_ee6c_abc9792bf48b["HTTPException"]
  96278b4c_a391_681f_b974_563be8af72ce --> 53e07af2_3e5c_ea1f_ee6c_abc9792bf48b
  7f688779_6b22_3c15_6514_97dec91c3c30["models.py"]
  96278b4c_a391_681f_b974_563be8af72ce --> 7f688779_6b22_3c15_6514_97dec91c3c30
  7b709818_b832_ceea_aedf_a621ca961213["HTTPBase"]
  96278b4c_a391_681f_b974_563be8af72ce --> 7b709818_b832_ceea_aedf_a621ca961213
  cbf7e9f4_5b47_5b2f_e074_1ccf62a4f2a4["HTTPBearer"]
  96278b4c_a391_681f_b974_563be8af72ce --> cbf7e9f4_5b47_5b2f_e074_1ccf62a4f2a4
  81864ff4_3194_3d8a_0ac8_a6193fbdc833["base.py"]
  96278b4c_a391_681f_b974_563be8af72ce --> 81864ff4_3194_3d8a_0ac8_a6193fbdc833
  1aa22226_1c87_90b6_c61d_502d10cd0315["SecurityBase"]
  96278b4c_a391_681f_b974_563be8af72ce --> 1aa22226_1c87_90b6_c61d_502d10cd0315
  de19417f_f5be_8d95_6a5d_91ed8317a398["utils.py"]
  96278b4c_a391_681f_b974_563be8af72ce --> de19417f_f5be_8d95_6a5d_91ed8317a398
  21dea0a2_f30d_d3da_ce48_734fa9836d52["get_authorization_scheme_param"]
  96278b4c_a391_681f_b974_563be8af72ce --> 21dea0a2_f30d_d3da_ce48_734fa9836d52
  6913fbd4_39df_d14b_44bb_522e99b65b90["pydantic"]
  96278b4c_a391_681f_b974_563be8af72ce --> 6913fbd4_39df_d14b_44bb_522e99b65b90
  style 96278b4c_a391_681f_b974_563be8af72ce fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import binascii
from base64 import b64decode
from typing import Annotated, Optional

from annotated_doc import Doc
from fastapi.exceptions import HTTPException
from fastapi.openapi.models import HTTPBase as HTTPBaseModel
from fastapi.openapi.models import HTTPBearer as HTTPBearerModel
from fastapi.security.base import SecurityBase
from fastapi.security.utils import get_authorization_scheme_param
from pydantic import BaseModel
from starlette.requests import Request
from starlette.status import HTTP_401_UNAUTHORIZED


class HTTPBasicCredentials(BaseModel):
    """
    The HTTP Basic credentials given as the result of using `HTTPBasic` in a
    dependency.

    Read more about it in the
    [FastAPI docs for HTTP Basic Auth](https://fastapi.tiangolo.com/advanced/security/http-basic-auth/).
    """

    username: Annotated[str, Doc("The HTTP Basic username.")]
    password: Annotated[str, Doc("The HTTP Basic password.")]


class HTTPAuthorizationCredentials(BaseModel):
    """
    The HTTP authorization credentials in the result of using `HTTPBearer` or
    `HTTPDigest` in a dependency.

    The HTTP authorization header value is split by the first space.

    The first part is the `scheme`, the second part is the `credentials`.

    For example, in an HTTP Bearer token scheme, the client will send a header
    like:

    ```
    Authorization: Bearer deadbeef12346
    ```

    In this case:

    * `scheme` will have the value `"Bearer"`
    * `credentials` will have the value `"deadbeef12346"`
    """

    scheme: Annotated[
        str,
        Doc(
            """
            The HTTP authorization scheme extracted from the header value.
            """
        ),
    ]
    credentials: Annotated[
        str,
// ... (364 more lines)

Domain

Subdomains

Dependencies

Frequently Asked Questions

What does http.py do?
http.py is a source file in the fastapi codebase, written in python. It belongs to the Security domain, Schemes subdomain.
What does http.py depend on?
http.py imports 16 module(s): HTTPBase, HTTPBearer, HTTPException, SecurityBase, annotated_doc, base.py, base64, binascii, and 8 more.
What files import http.py?
http.py is imported by 4 file(s): __init__.py, test_security_http_base.py, test_security_http_base_description.py, test_security_http_base_optional.py.
Where is http.py in the architecture?
http.py is located at fastapi/security/http.py (domain: Security, subdomain: Schemes, directory: fastapi/security).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free