Simple user session protection for Flask applications.
  • Python 85.9%
  • HTML 14.1%
Find a file
Miguel Grinberg 1d8096ea09
All checks were successful
build / tests-3.10 (push) Successful in 35s
build / tests-3.11 (push) Successful in 33s
build / lint (push) Successful in 59s
build / tests-3.12 (push) Successful in 45s
build / tests-3.13 (push) Successful in 47s
build / zizmor (push) Successful in 9s
build / tests-3.14 (push) Successful in 54s
build / tests-pypy-3.11 (push) Successful in 1m47s
Update project URLs in metadata
2026-08-29 23:55:46 +01:00
.forgejo/workflows Forgejo migration 2026-08-29 20:27:48 +01:00
docs documentation fixes 2017-07-01 23:57:00 -07:00
example Bump werkzeug from 2.0.2 to 2.2.3 in /example (#12) #nolog 2023-02-16 10:05:57 +00:00
src/flask_paranoid project restructure and test fixes 2022-04-02 17:14:30 +01:00
tests project restructure and test fixes 2022-04-02 17:14:30 +01:00
.gitignore add zizmor to ci 2026-05-13 20:05:54 +01:00
.readthedocs.yaml Forgejo migration 2026-08-29 20:27:48 +01:00
.travis.yml tox and travis build setup 2017-07-01 00:02:44 -07:00
CHANGES.md Release 0.3.0 2022-04-02 17:26:49 +01:00
CODE_OF_CONDUCT.md Forgejo migration 2026-08-29 20:27:48 +01:00
CONTRIBUTING.md Forgejo migration 2026-08-29 20:27:48 +01:00
LICENSE initial commit 2017-06-29 23:14:47 -07:00
MANIFEST.in Migrate Python package metadata to pyproject.toml 2023-10-15 14:23:40 +01:00
pyproject.toml Update project URLs in metadata 2026-08-29 23:55:46 +01:00
README.md Forgejo migration 2026-08-29 20:27:48 +01:00
SECURITY.md Forgejo migration 2026-08-29 20:27:48 +01:00
setup.cfg Version 0.3.1.dev0 2022-04-02 17:27:10 +01:00
setup.py project restructure and test fixes 2022-04-02 17:14:30 +01:00
tox.ini tox configuration 2026-05-14 23:19:31 +01:00

flask-paranoid

tests

Simple user session protection.

Quick Start

Here is a simple application that uses Flask-Paranoid to protect the user session:

from flask import Flask
from flask_paranoid import Paranoid

app = Flask(__name__)
app.config['SECRET_KEY'] = 'top-secret!'

paranoid = Paranoid(app)
paranoid.redirect_view = '/'

@app.route('/')
def index():
    return render_template('index.html')

When a client connects to this application, a "paranoid" token will be generated according to the IP address and user agent. In all subsequent requests, the token will be recalculated and checked against the one computed for the first request. If the session cookie is stolen and the attacker tries to use it from another location, the generated token will be different, and in that case the extension will clear the session and block the request.

Resources

Sponsor this project

This project relies on contributions from its users. If you benefit from it please consider making a single or ongoing monetary contribution in one of the following platforms:

Thank you!