多路径使用其危险性的身份策略。
more.itsdangerous的Python项目详细描述
用法
importmorepathfrommore.itsdangerousimportIdentityPolicyclassApp(morepath.App):pass@App.identity_policy()defget_identity_policy():returnIdentityPolicy()@App.verify_identity()defverify_identity(identity):# trust the identity established by the identity policy (we could keep# checking if the user is really in the database here - or if it was# removed in the meantime)returnTrue
查看http://morepath.readthedocs.org/en/latest/security.html了解更多 关于morepath的安全模型 查看注释过的源代码:
https://github.com/morepath/more.itsdangerous/blob/master/more/itsdangerous/identity_policy.py
identitypolicy类是要扩展的,因为每个人都有不同的 需要。它只是提供了一种方法,使用 很危险。
开发中的使用
默认情况下,more创建的cookie是危险的 HttpOnly和 Secure。
如果您有不同的需求,或者运行的是开发服务器,则 可能需要更改标识策略的配置:
@App.identity_policy()defget_identity_policy():# make the cookies work under http, not just httpsreturnIdentityPolicy(secure=False)
请注意,这只应用于开发。在这个时代 不想通过http传输cookies!
运行测试
安装tox并运行它:
pip install tox tox
将测试限制为特定的python版本:
tox -e py27
许可证
更多。根据修订的BSD许可证发布危险信息
更改日志
0.0.2(2016-04-18)
- 添加与morepath 0.14+的兼容性。 [亨利·胡尔斯基]
0.0.1(2015-04-29)
- 初次发行 [资源]