基于envauth环境变量的身份验证
envauth的Python项目详细描述
超级简单的身份验证中间件,当您快速需要密码时 保护某些内容,而没有时间实施严格的身份验证。 支持现成的Flask、bottle、Django和通用的WSGI服务器。
$envauth
envauth在ENVAUTH环境变量中查找JSON对象。 密钥是用户名,值包含用户的密码。
{"username":"password","anotheruser":"pass1234"}
Heroku示例
envauth在paas上运行应用程序时特别有用!
$ heroku config:set ENVAUTH='{"username": "password", "anotheruser": "pass1234"}' Setting config vars and restarting application... done, v2
示例
烧瓶
importenvauth@app.route('/secret-page')@envauth.flask.requires_auth(realm='You shall not pass!')defsecret_page():returnrender_template('secret_page.html')
瓶子
importenvauth@app.route('/secret-page')@envauth.bottle.requires_auth(realm='You shall not pass!')defsecret_page():returntemplate('secret_page.html')
django
MIDDLEWARE_CLASSES+=('envauth.django',)
wsgi
importenvauthapplication=envauth.wsgi(application,realm='You shall not pass!')
安装
使用pip:
安装envauth$ pip install envauth