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

Uploaded Python 3

File details

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

File metadata

  • Download URL: fastapi_login_shield-0.1.4.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.4.tar.gz
Algorithm Hash digest
SHA256 2e566641cd03849f32111d775a59f7e44a683598eceb04c06afadfa258d9d4b7
MD5 dc0504dd6b8535bf490f8299366071e2
BLAKE2b-256 64df4c4424b6c6da4fb2b3b59bbcc88b11013e2824b1c010ab336f2badd0045d

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for fastapi_login_shield-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 e3e5e678998b7a491f2f182a92e2bd98b1c50164e7079d247821e3de28bca7e4
MD5 c8e222a0f3535295968eca77f6af0c24
BLAKE2b-256 91e8a7cf09f2177551d4d15d5d5d6921bbd9d4cbdf3d4a6abe118afca4689647

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