保护web框架免受密码暴力攻击的模块
redissentry-core的Python项目详细描述
这是一般的再发现文件,对于django特定的注释, 见Django再发现文件。
安装
这就是如何将redisentry集成到任何python驱动的项目中(例如flask):
from redissentry import RedisSentry def protected_auth(username, password): sentry = RedisSentry(ip, username) msg = sentry.ask() if msg: raise Exception(msg) res = auth(username, password) msg = sentry.inform(bool(res)) if not res: raise Exception('Incorrect username or password. ' + msg) return res
其中auth()是原始的auth函数。