【问题标题】:(Session) authentication in a pyramids web application金字塔 Web 应用程序中的(会话)身份验证
【发布时间】:2012-08-10 03:39:50
【问题描述】:

我正在开发一个基于金字塔框架的 python web 应用程序。我正在尝试向它添加会话身份验证。据我了解:

  • 用户可以登录/退出(需要安全);用户数据保存在数据库中
  • 身份验证通过会话处理 (request.session)

首先:会话身份验证是一个好的选择还是有更好的选择? 其次:我无法真正了解文档和示例。

到目前为止,我已经关注了http://docs.pylonsproject.org/projects/pyramid/en/1.3-branch/tutorials/wiki2/authorization.html#adding-login-and-logout-views,我有一个登录/注销表单。但是,我的authn_policy 是http://docs.pylonsproject.org/projects/pyramid/en/latest/api/authentication.html#pyramid.authentication.SessionAuthenticationPolicy

由于金字塔中的会话工厂不安全(请参阅http://docs.pylonsproject.org/projects/pyramid/en/1.3-branch/narr/sessions.html),我使用 *pyramid_beaker* 代替。

配置是: 在__init__.py:session_factory = session_factory_from_settings(settings)

在 .ini 文件中:

beaker.session.lock_dir = %(here)s/data/sessions/lock
beaker.session.type = ext:database
beaker.session.sa.url = mysql://user:pass@localhost:3306/db
beaker.session.table_name = user_session

我希望我能把我的问题说清楚。

【问题讨论】:

    标签: python pyramid beaker


    【解决方案1】:

    我会说这取决于你想做什么。如果您使用 Beaker,会话身份验证可以正常工作,但我喜欢使用 AuthTktAuthenticationPolicy 来获得额外的超时和重新发布选项,并且即使您清除会话,您的身份验证也不会消失。

    【讨论】:

    • 请详细说明... 使用 Beaker 进行会话时是否不存在超时和重新发布选项?
    • 不管你使用什么会话,标准的 SessionAuthenticationPolicy 没有选项。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-08-11
    • 2012-09-09
    • 2017-02-10
    • 1970-01-01
    • 2015-08-27
    • 2018-03-05
    • 1970-01-01
    相关资源
    最近更新 更多