https://github.com/douganger/flask-ipfilter
A simple Flask extension to limit access to a site to certain IP addresses.
https://github.com/douganger/flask-ipfilter
flask heroku python3 security
Last synced: 3 months ago
JSON representation
A simple Flask extension to limit access to a site to certain IP addresses.
- Host: GitHub
- URL: https://github.com/douganger/flask-ipfilter
- Owner: douganger
- License: mit
- Created: 2019-03-05T23:53:32.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2023-02-15T21:20:16.000Z (over 2 years ago)
- Last Synced: 2025-03-26T07:36:34.293Z (4 months ago)
- Topics: flask, heroku, python3, security
- Language: Python
- Homepage: https://flask-ipfilter.readthedocs.io/
- Size: 97.7 KB
- Stars: 4
- Watchers: 1
- Forks: 1
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Flask-IPFilter
[](https://travis-ci.org/douganger/flask-ipfilter)
[](https://coveralls.io/github/douganger/flask-ipfilter?branch=master)
[](https://flask-ipfilter.readthedocs.io/en/latest/?badge=latest)
[](https://www.codacy.com/gh/douganger/flask-ipfilter/dashboard)Flask-IPFilter is a simple Flask extension to limit access to a site to certain
IP addresses. The current implementation is a minimal proof of concept with one
important limitation:- The current implementation trusts the X-Forwarded-For header and uses the
last IP address in that header if multiple IP addresses are listed.## Quickstart
Install Flask-IPFilter with the command, `pip install flask-ipfilter`.
The following minimal Flask application demonstrates how to use Flask-IPFilter
in your application.```python
from flask import Flask
from flask_ipfilter import IPFilter, Whitelistapp = Flask(__name__)
ip_filter = IPFilter(app, ruleset=Whitelist())ip_filter.ruleset.permit("127.0.0.1")
@app.route("/")
def route_test():
return "Allowed."
```