On 06/20/2012 10:07 AM, Ben Sizer wrote:
> I have set up my Session object the usual way, via a session factory, etc.
>
> SessionAuthenticationPolicy looks like exactly what I need, but are
> there any examples of its use? It would be handy to know where it pulls
> userids from, for example. Also it seems to want to be reading and
> writing auth values to the session itself, so does that affect how I
> have mark a user as logged in?
See the "callback" argument to its constructor. It's meant to be a
function that accepts a user id and returns one of:
- A sequence of group ids
- An empty sequence (no groups associated with the user)
- None
If it returns None, it means that the userid doesn't exist in the
database. If it returns a sequence (either empty or populated), it
means the user exists in the database.
How you implement the callback is up to you. If you don't implement the
callback, the userid is taken from the session without any checking.
See either of the two tutorials in
http://docs.pylonsproject.org/projects/pyramid_tutorials/en/latest/wiki_tutorials.html
for examples of how Pyramid security works. It's irrelevant which
authentication policy is in use, all of them work more or less the same.
http://docs.pylonsproject.org/projects/pyramid_cookbook/en/latest/auth/wiki2_auth.html
has a more detailed description of how security works in the wiki2 tutorial.
> I'd also like to know whether there is any support for getting an
> automatically populated User object, eg. "request.current_user",
> although if necessary I'm happy to do this manually in each view.
http://docs.pylonsproject.org/projects/pyramid_cookbook/en/latest/auth/user_object.html
>
pylons-...@googlegroups.com
> <mailto:
pylons-...@googlegroups.com>.
> > To unsubscribe from this group, send email to
> >
pylons-discus...@googlegroups.com
> <mailto:
pylons-discuss%2Bunsu...@googlegroups.com>.
> <
http://groups.google.com/group/pylons-discuss?hl=en>.
> >
>
> --
> You received this message because you are subscribed to the Google
> Groups "pylons-discuss" group.
> To view this discussion on the web visit
>
https://groups.google.com/d/msg/pylons-discuss/-/-I5cRbkh8i0J.
> To post to this group, send email to
pylons-...@googlegroups.com.
> To unsubscribe from this group, send email to
>
pylons-discus...@googlegroups.com.