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

Uploaded Python 3

File details

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

File metadata

  • Download URL: fastapi_login_shield-0.1.1.tar.gz
  • Upload date:
  • Size: 1.6 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.1.tar.gz
Algorithm Hash digest
SHA256 d9ac954ed69ab1125fc8b5db7b18808378fcafcff36fac06d49d77eaeb44161e
MD5 5a059033f4eaac747a917037e3542061
BLAKE2b-256 8db9780113e6eadc09ca7cf5a7d177b80f57761c6182c5a4195808834aa69bc6

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for fastapi_login_shield-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 f9d0299d73bee14d6cc86f354c4211a75d7b511fab935fce5124f542a2811b32
MD5 b7688da101727a95d1b148ec4414d232
BLAKE2b-256 5a9a505f3761246c00ddf95815eb8a650b09838505d3f01cf9b44d1a339aaabf

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