Skip to main content
Donate to the Python Software Foundation or Purchase a PyCharm License to Benefit the PSF! Donate Now

HTTP spam security for Flask.

Project description

PyPI Version

IpBan is a Flask extension that can help protect against ip locations spamming url requests against unknown pages. Often this is to search for security issues.

The default configuration:

  • 50 attempts before ban
  • 1 hour blocking period

Installation & Basic Usage

Install via pip:

pip install flask-ipban

After installing, wrap your Flask app with a IpBan:

from flask import Flask
from flask_ipban import IpBan

app = Flask(__name__)
IpBan(app)

Enclosed is a small example application

Options

  • ban_count, default 50, Number of observations before banning
  • ban_seconds, default 60, Number of seconds ip address is banned
  • ip_ban.block(ip_address, permanent=True) - block the specific address forever
  • ip_ban.add(reason='spite') - increase the observation for the current request ip

Per-view options

Example code

from flask import Flask
from flask_ipban import IpBan

app = Flask(__name__)
ip_ban = IpBan(app)

@app.route('/normal')
def normal():
    return 'Normal'

Licensing

  • Apache 2.0

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
flask_ipban-0.1.4-py2.py3-none-any.whl (9.9 kB) Copy SHA256 hash SHA256 Wheel py2.py3

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page