Home / File/ tutorial005_an_py39.py — fastapi Source File

tutorial005_an_py39.py — fastapi Source File

Architecture documentation for tutorial005_an_py39.py, a python file in the fastapi codebase. 8 imports, 0 dependents.

File python FastAPI Applications 8 imports 11 functions 4 classes

Entity Profile

Dependency Diagram

graph LR
  874d355e_5626_0709_a216_de8189208c14["tutorial005_an_py39.py"]
  e973e384_8276_b242_eb98_1c0b79a84e68["datetime"]
  874d355e_5626_0709_a216_de8189208c14 --> e973e384_8276_b242_eb98_1c0b79a84e68
  0dda2280_3359_8460_301c_e98c77e78185["typing"]
  874d355e_5626_0709_a216_de8189208c14 --> 0dda2280_3359_8460_301c_e98c77e78185
  822acfd3_718b_c215_daf1_986b6791f3bd["jwt"]
  874d355e_5626_0709_a216_de8189208c14 --> 822acfd3_718b_c215_daf1_986b6791f3bd
  534f6e44_61b8_3c38_8b89_6934a6df9802["__init__.py"]
  874d355e_5626_0709_a216_de8189208c14 --> 534f6e44_61b8_3c38_8b89_6934a6df9802
  35c4ea20_c454_5afd_6cda_f0818bbcc650["__init__.py"]
  874d355e_5626_0709_a216_de8189208c14 --> 35c4ea20_c454_5afd_6cda_f0818bbcc650
  96400ec7_7fe7_41d2_404e_d92498b1ac31["jwt.exceptions"]
  874d355e_5626_0709_a216_de8189208c14 --> 96400ec7_7fe7_41d2_404e_d92498b1ac31
  640a3b96_2dad_7fba_4cb0_187a74ec8604["pwdlib"]
  874d355e_5626_0709_a216_de8189208c14 --> 640a3b96_2dad_7fba_4cb0_187a74ec8604
  6913fbd4_39df_d14b_44bb_522e99b65b90["pydantic"]
  874d355e_5626_0709_a216_de8189208c14 --> 6913fbd4_39df_d14b_44bb_522e99b65b90
  style 874d355e_5626_0709_a216_de8189208c14 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

from datetime import datetime, timedelta, timezone
from typing import Annotated, Union

import jwt
from fastapi import Depends, FastAPI, HTTPException, Security, status
from fastapi.security import (
    OAuth2PasswordBearer,
    OAuth2PasswordRequestForm,
    SecurityScopes,
)
from jwt.exceptions import InvalidTokenError
from pwdlib import PasswordHash
from pydantic import BaseModel, ValidationError

# to get a string like this run:
# openssl rand -hex 32
SECRET_KEY = "09d25e094faa6ca2556c818166b7a9563b93f7099f6f0f4caa6cf63b88e8d3e7"
ALGORITHM = "HS256"
ACCESS_TOKEN_EXPIRE_MINUTES = 30


fake_users_db = {
    "johndoe": {
        "username": "johndoe",
        "full_name": "John Doe",
        "email": "johndoe@example.com",
        "hashed_password": "$argon2id$v=19$m=65536,t=3,p=4$wagCPXjifgvUFBzq4hqe3w$CYaIb8sB+wtD+Vu/P4uod1+Qof8h+1g7bbDlBID48Rc",
        "disabled": False,
    },
    "alice": {
        "username": "alice",
        "full_name": "Alice Chains",
        "email": "alicechains@example.com",
        "hashed_password": "$argon2id$v=19$m=65536,t=3,p=4$g2/AV1zwopqUntPKJavBFw$BwpRGDCyUHLvHICnwijyX8ROGoiUPwNKZ7915MeYfCE",
        "disabled": True,
    },
}


class Token(BaseModel):
    access_token: str
    token_type: str


class TokenData(BaseModel):
    username: Union[str, None] = None
    scopes: list[str] = []


class User(BaseModel):
    username: str
    email: Union[str, None] = None
    full_name: Union[str, None] = None
    disabled: Union[bool, None] = None


class UserInDB(User):
    hashed_password: str


// ... (120 more lines)

Domain

Subdomains

Dependencies

Frequently Asked Questions

What does tutorial005_an_py39.py do?
tutorial005_an_py39.py is a source file in the fastapi codebase, written in python. It belongs to the FastAPI domain, Applications subdomain.
What functions are defined in tutorial005_an_py39.py?
tutorial005_an_py39.py defines 11 function(s): authenticate_user, create_access_token, get_current_active_user, get_current_user, get_password_hash, get_user, login_for_access_token, read_own_items, read_system_status, read_users_me, and 1 more.
What does tutorial005_an_py39.py depend on?
tutorial005_an_py39.py imports 8 module(s): __init__.py, __init__.py, datetime, jwt, jwt.exceptions, pwdlib, pydantic, typing.
Where is tutorial005_an_py39.py in the architecture?
tutorial005_an_py39.py is located at docs_src/security/tutorial005_an_py39.py (domain: FastAPI, subdomain: Applications, directory: docs_src/security).

Analyze Your Own Codebase

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

Try Supermodel Free