tutorial004_py310.py — fastapi Source File
Architecture documentation for tutorial004_py310.py, a python file in the fastapi codebase. 7 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 94431617_6d9c_db53_7d48_f9b8408147c2["tutorial004_py310.py"] e973e384_8276_b242_eb98_1c0b79a84e68["datetime"] 94431617_6d9c_db53_7d48_f9b8408147c2 --> e973e384_8276_b242_eb98_1c0b79a84e68 822acfd3_718b_c215_daf1_986b6791f3bd["jwt"] 94431617_6d9c_db53_7d48_f9b8408147c2 --> 822acfd3_718b_c215_daf1_986b6791f3bd 534f6e44_61b8_3c38_8b89_6934a6df9802["__init__.py"] 94431617_6d9c_db53_7d48_f9b8408147c2 --> 534f6e44_61b8_3c38_8b89_6934a6df9802 35c4ea20_c454_5afd_6cda_f0818bbcc650["__init__.py"] 94431617_6d9c_db53_7d48_f9b8408147c2 --> 35c4ea20_c454_5afd_6cda_f0818bbcc650 96400ec7_7fe7_41d2_404e_d92498b1ac31["jwt.exceptions"] 94431617_6d9c_db53_7d48_f9b8408147c2 --> 96400ec7_7fe7_41d2_404e_d92498b1ac31 640a3b96_2dad_7fba_4cb0_187a74ec8604["pwdlib"] 94431617_6d9c_db53_7d48_f9b8408147c2 --> 640a3b96_2dad_7fba_4cb0_187a74ec8604 6913fbd4_39df_d14b_44bb_522e99b65b90["pydantic"] 94431617_6d9c_db53_7d48_f9b8408147c2 --> 6913fbd4_39df_d14b_44bb_522e99b65b90 style 94431617_6d9c_db53_7d48_f9b8408147c2 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
from datetime import datetime, timedelta, timezone
import jwt
from fastapi import Depends, FastAPI, HTTPException, status
from fastapi.security import OAuth2PasswordBearer, OAuth2PasswordRequestForm
from jwt.exceptions import InvalidTokenError
from pwdlib import PasswordHash
from pydantic import BaseModel
# 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,
}
}
class Token(BaseModel):
access_token: str
token_type: str
class TokenData(BaseModel):
username: str | None = None
class User(BaseModel):
username: str
email: str | None = None
full_name: str | None = None
disabled: bool | None = None
class UserInDB(User):
hashed_password: str
password_hash = PasswordHash.recommended()
oauth2_scheme = OAuth2PasswordBearer(tokenUrl="token")
app = FastAPI()
def verify_password(plain_password, hashed_password):
return password_hash.verify(plain_password, hashed_password)
def get_password_hash(password):
return password_hash.hash(password)
// ... (81 more lines)
Domain
Subdomains
Functions
Dependencies
- __init__.py
- __init__.py
- datetime
- jwt
- jwt.exceptions
- pwdlib
- pydantic
Source
Frequently Asked Questions
What does tutorial004_py310.py do?
tutorial004_py310.py is a source file in the fastapi codebase, written in python. It belongs to the FastAPI domain, Responses subdomain.
What functions are defined in tutorial004_py310.py?
tutorial004_py310.py defines 10 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_users_me, verify_password.
What does tutorial004_py310.py depend on?
tutorial004_py310.py imports 7 module(s): __init__.py, __init__.py, datetime, jwt, jwt.exceptions, pwdlib, pydantic.
Where is tutorial004_py310.py in the architecture?
tutorial004_py310.py is located at docs_src/security/tutorial004_py310.py (domain: FastAPI, subdomain: Responses, directory: docs_src/security).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free