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.2.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.2-py3-none-any.whl (2.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: fastapi_login_shield-0.1.2.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.2.tar.gz
Algorithm Hash digest
SHA256 e97f005a8e46e0e0f654b60451ccd4a502e4b23c086ec2e21a409bb59914b26a
MD5 5b90c8cd6893835e8ab24e1d2e0e2acd
BLAKE2b-256 b2d573f017d4b563f7489a225540746d6a64e270108a58af9b573de180f7d817

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for fastapi_login_shield-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 d826f2bc2aba47384480dd0435384912cc28f99f10b2be9a7f9e705143922722
MD5 f793734e0913daf42808d169e3fd267f
BLAKE2b-256 71da166739639fe4bbb139c69cee55212094a2bc356f68adc25c69e323c6b7ca

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