HTTPDigest Class — fastapi Architecture
Architecture documentation for the HTTPDigest class in http.py from the fastapi codebase.
Entity Profile
Dependency Diagram
graph TD 787896c0_cb31_1b11_93c2_5e2fac3ff58e["HTTPDigest"] 7b709818_b832_ceea_aedf_a621ca961213["HTTPBase"] 787896c0_cb31_1b11_93c2_5e2fac3ff58e -->|extends| 7b709818_b832_ceea_aedf_a621ca961213 96278b4c_a391_681f_b974_563be8af72ce["http.py"] 787896c0_cb31_1b11_93c2_5e2fac3ff58e -->|defined in| 96278b4c_a391_681f_b974_563be8af72ce 013b85a6_a1fa_f855_6dc6_f0b56dff5dc6["__init__()"] 787896c0_cb31_1b11_93c2_5e2fac3ff58e -->|method| 013b85a6_a1fa_f855_6dc6_f0b56dff5dc6 1cc0e9d7_5f1e_8998_ada2_046b7c502577["__call__()"] 787896c0_cb31_1b11_93c2_5e2fac3ff58e -->|method| 1cc0e9d7_5f1e_8998_ada2_046b7c502577
Relationship Graph
Source Code
fastapi/security/http.py lines 323–423
class HTTPDigest(HTTPBase):
"""
HTTP Digest authentication.
**Warning**: this is only a stub to connect the components with OpenAPI in FastAPI,
but it doesn't implement the full Digest scheme, you would need to to subclass it
and implement it in your code.
Ref: https://datatracker.ietf.org/doc/html/rfc7616
## Usage
Create an instance object and use that object as the dependency in `Depends()`.
The dependency result will be an `HTTPAuthorizationCredentials` object containing
the `scheme` and the `credentials`.
## Example
```python
from typing import Annotated
from fastapi import Depends, FastAPI
from fastapi.security import HTTPAuthorizationCredentials, HTTPDigest
app = FastAPI()
security = HTTPDigest()
@app.get("/users/me")
def read_current_user(
credentials: Annotated[HTTPAuthorizationCredentials, Depends(security)]
):
return {"scheme": credentials.scheme, "credentials": credentials.credentials}
```
"""
def __init__(
self,
*,
scheme_name: Annotated[
Optional[str],
Doc(
"""
Security scheme name.
It will be included in the generated OpenAPI (e.g. visible at `/docs`).
"""
),
] = None,
description: Annotated[
Optional[str],
Doc(
"""
Security scheme description.
It will be included in the generated OpenAPI (e.g. visible at `/docs`).
"""
),
] = None,
auto_error: Annotated[
bool,
Doc(
"""
By default, if the HTTP Digest is not provided, `HTTPDigest` will
automatically cancel the request and send the client an error.
If `auto_error` is set to `False`, when the HTTP Digest 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 HTTP
Digest or in a cookie).
"""
),
] = True,
):
Domain
Defined In
Extends
Source
Frequently Asked Questions
What is the HTTPDigest class?
HTTPDigest is a class in the fastapi codebase, defined in fastapi/security/http.py.
Where is HTTPDigest defined?
HTTPDigest is defined in fastapi/security/http.py at line 323.
What does HTTPDigest extend?
HTTPDigest extends HTTPBase.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free