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.0.tar.gz (1.9 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.0-py3-none-any.whl (3.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fastapi_login_shield-0.1.0.tar.gz
  • Upload date:
  • Size: 1.9 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.0.tar.gz
Algorithm Hash digest
SHA256 a7f4471f6acf7f834edbd891b464079e4c03500f5fdcee589e856fe2c826c67a
MD5 255d950906b04e9b8f297675ab60d429
BLAKE2b-256 261c3f678ad1ff031632f67057bcd0abafeec2bec81357e664f0c4135a8434af

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for fastapi_login_shield-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dc0a2f1fb78246455291a20754703b8a3cbcfe8e6866d7f407ca10c876540706
MD5 fa63a5821353ca8966ddc36c8130538d
BLAKE2b-256 768054771196b61738537d5dc7a14c0ed28468635e56262ecfef9db16b577044

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