GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • FasterApiWeb/FasterAPI
  • Home
  • Getting Started
  • Tutorial
  • Advanced User Guide
  • Security
  • Databases
  • Deployment
  • Concepts
  • How-To Recipes
  • Reference
  • FAQ & Troubleshooting
  • Path Parameters
  • Query Parameters

This view

  • Original page
  • New address

GeezerVison is showing fasterapiweb.github.io — Introduction - FasterAPI

Security¶

Security is an important — and often underestimated — part of API development. This section covers authentication and authorisation patterns for FasterAPI.

Pages¶

Topic What you learn
OAuth2 with Password + JWT Bearer tokens, login endpoint, protected routes
OAuth2 Scopes Fine-grained permission checks
HTTP Basic Auth Simple username / password authentication

Core concepts¶

Authentication vs authorisation¶

  • Authentication — verifying who a user is (login, token validation).
  • Authorisation — verifying what a user may do (role checks, scopes).

Secrets and keys¶

  • Store secrets in environment variables, never in code or version control.
  • Use a cryptographically secure random value for SECRET_KEY:
python -c "import secrets; print(secrets.token_hex(32))"

HTTPS¶

Always serve your API over HTTPS in production so credentials are not transmitted in plain text. See Behind a Proxy and Deployment for setup guidance.

Dependency-based security¶

FasterAPI's Depends() system is well-suited for security: declare an auth dependency once and reuse it across many routes.

from FasterAPI import Depends, HTTPException, Header


async def require_auth(authorization: str | None = Header(default=None)):
    if not authorization:
        raise HTTPException(status_code=401, detail="Not authenticated")
    # validate token here
    return parse_token(authorization)

Next steps¶

  • Start with OAuth2 with Password + JWT for the most common pattern.
  • For simple internal tools, HTTP Basic Auth may be sufficient.
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.