FastAPI 0.162

Last reviewed Oct 24, 2026

Export as PDF

Prompt Details

Prompt Composition

3prompts
  1. Python 3155 lines · 3.8K tokens
  2. Pydantic 2.1356 lines · 1.3K tokens
  3. FastAPI 0.16262 lines · 3.2K tokens
Total273 lines · 8.3K tokens

CWE Coverage

  • 20
  • 23
  • 36
  • 59
  • 73
  • 78
  • 79
  • 89
  • 95
  • 117
  • 201
  • 208
  • 209
  • 214
  • 250
  • 295
  • 306
  • 307
  • 319
  • 328
  • 338
  • 347
  • 352
  • 367
  • 379
  • 384
  • 409
  • 416
  • 426
  • 427
  • 434
  • 470
  • 502
  • 525
  • 532
  • 552
  • 598
  • 601
  • 611
  • 613
  • 614
  • 639
  • 674
  • 732
  • 770
  • 772
  • 776
  • 807
  • 829
  • 862
  • 915
  • 916
  • 918
  • 942
  • 1004
  • 1104
  • 1275
  • 1284
  • 1287
  • 1333
  • 1385
  • 1395

Prompt Preview

Apply the included Pydantic 2.13 and Python 3 prompts. These rules cover FastAPI 0.162 applications, their dependencies, request and response handling, and deployment boundaries.

Authentication and authorization

  • If adding Starlette Route entries with HTTPEndpoint classes, set an explicit methods allowlist and authorize every enabled handler, including HEAD where applicable; do not assume FastAPI path-operation dependencies protect direct Starlette routes.
  • Put authentication and authorization in Depends or Security dependencies attached to every protected path operation or router. Check mounted applications separately; a parent application's dependencies do not secure an independent mounted app.
  • Treat OAuth2PasswordBearer, HTTPBearer, and API-key helpers as credential extractors, not token verification. Verify the credential, load the current principal, reject disabled accounts, and authorize the operation and tenant-scoped object before side effects. With auto_error=False, explicitly reject missing credentials on protected routes. Send API keys in headers rather than query strings, and exclude them from examples and request logs.
  • In JWT dependencies, apply the baseline's signature, issuer, audience, and expiry checks before trusting sub or scopes. Validate the subject and claim types; never let a signed token's resource identifier replace an object-access check. When tokens are verified with PyJWT, as the FastAPI tutorial does, also apply the PyJWT prompt.
  • Enforce every scope in SecurityScopes.scopes in application code. When issuing