Skip to main content

Protect FastAPI login endpoints from brute-force attacks

Project description

fastapi-login-shield

A minimal FastAPI middleware to prevent brute-force login attempts based on client IP.

Features

  • IP-based login rate limiting
  • Exponential backoff delays
  • Lightweight, no Redis required

Usage

from fastapi import FastAPI, Request
from fastapi_login_shield import LoginShieldMiddleware, register_login_result

app = FastAPI()
app.add_middleware(LoginShieldMiddleware, login_path="/login")

@app.post("/login")
async def login(request: Request):
    ip = request.headers.get("X-Forwarded-For", request.client.host)
    ...
    await register_login_result(ip, success=True|False)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fastapi_login_shield-0.1.5.tar.gz (1.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fastapi_login_shield-0.1.5-py3-none-any.whl (2.6 kB view details)

Uploaded Python 3

File details

Details for the file fastapi_login_shield-0.1.5.tar.gz.

File metadata

  • Download URL: fastapi_login_shield-0.1.5.tar.gz
  • Upload date:
  • Size: 1.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for fastapi_login_shield-0.1.5.tar.gz
Algorithm Hash digest
SHA256 f248f0a13d8552d4f7cffce0177692e44fb07e4caad233e9e1ccf5a732fb767b
MD5 7a22f1230dc8370fa403d39a92026eab
BLAKE2b-256 0bd40e74684d1a1b34217e19ea0db28dc57e1db5a537bc3aaf9c279ac797c5dd

See more details on using hashes here.

File details

Details for the file fastapi_login_shield-0.1.5-py3-none-any.whl.

File metadata

File hashes

Hashes for fastapi_login_shield-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 93d2f5ae6a711754cc9d586d20c8c012dff038f6179cc341d47e7f581ac5e042
MD5 108a83ab8797763417ed854e838e258b
BLAKE2b-256 58d66e84d911abb958e4a44e26bf9915810fa859e1331a907bd8c9f6f87dbf02

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page