简体   繁体   English

如何为会话和登录系统设置 pyramid_beaker?

[英]How do I setup pyramid_beaker for a sessions & login system?

I'm trying to follow the instructions here ( http://docs.pylonsproject.org/projects/pyramid_beaker/en/latest/ ) so I can setup a session/login system.我正在尝试按照此处的说明 ( http://docs.pylonsproject.org/projects/pyramid_beaker/en/latest/ ) 进行操作,以便我可以设置会话/登录系统。 The instructions are confusing me greatly.这些说明让我很困惑。 What exactly is the "default activation setup"? “默认激活设置”到底是什么? Does that mean there is already a config for the session factory when I call config.include('pyramid_beaker'), so that calling pyramid_beaker.BeakerSessionFactoryConfig() is unnecessary?这是否意味着当我调用 config.include('pyramid_beaker') 时已经有 session 工厂的配置,因此不需要调用 pyramid_beaker.BeakerSessionFactoryConfig()?

What's the easiest way I can a secure login/permissions system working with pyramid_beaker?我可以使用 pyramid_beaker 的安全登录/权限系统的最简单方法是什么?

Beaker is a library for handling caching and sessions (ie non-persistent data). Beaker 是一个用于处理缓存和会话(即非持久性数据)的库。 You can hijack a session and use it to store whether a user is logged in ( request.session['user_id'] = some_id or via pyramid.authentication.SessionAuthenticationPolicy ).您可以劫持 session 并使用它来存储用户是否已登录( request.session['user_id'] = some_id或通过pyramid.authentication.SessionAuthenticationPolicy )。 Both of these will simply store/track the current userid in a session instead of in some other cookie.这两者都将简单地在 session 中存储/跟踪当前用户 ID,而不是在其他 cookie 中。 Note, however, this has nothing to do with permissions or the workflow you use for handling user credentials and logging them in.但是请注意,这与您用于处理用户凭据和登录的权限工作流程无关。

Yes, config.include('pyramid_beaker') will automatically configure the cache regions and session factory for you via your INI settings (those settings are documented in the link you supplied as well as the separate beaker docs).是的, config.include('pyramid_beaker')将通过您的 INI 设置自动为您配置缓存区域和 session 工厂(这些设置记录在您提供的链接以及单独的烧杯文档中)。

The easiest way to setup a login/permissions system around this idea is to follow the wiki tutorial in the pyramid docs.围绕这个想法设置登录/权限系统的最简单方法是遵循金字塔文档中的 wiki 教程。 It shows how to log users in from SQLAlchemy using the AuthTktAuthenticationPolicy which you can easily replace with the SessionAuthenticationPolicy if you deem it necessary.它展示了如何使用AuthTktAuthenticationPolicy从 SQLAlchemy 登录用户,如果您认为有必要,您可以轻松地将其替换为SessionAuthenticationPolicy

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM