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.3.tar.gz (1.5 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.3-py3-none-any.whl (2.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fastapi_login_shield-0.1.3.tar.gz
  • Upload date:
  • Size: 1.5 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.3.tar.gz
Algorithm Hash digest
SHA256 2eb0385b0c52e4a744986e8750a03699e576961bb4d695d38b4b7b12b5e66744
MD5 6892ed0a2253ca21fa4de257f9bf45cc
BLAKE2b-256 ea54dcb0acf017691bdcdd53c9610a73c3bacb727d6e5554df42b6f1ec1b1f52

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for fastapi_login_shield-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 a88709a663ff22efcb045a3fab49022b394303b98af9184c6f810473a9d1bc9d
MD5 2ac45a8e0f1cf30a9913ed366e0e2402
BLAKE2b-256 1bf1575e5d273a065dd841f89da164a1b0a1da068b6b960892f03f6281481ffc

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