Giter Club home page Giter Club logo

repoze.who-use_beaker's Introduction

What is repoze.who-use_beaker

https://travis-ci.org/akissa/repoze.who-use_beaker.svg?branch=master Code Climate

repoze.who-use_beaker is a repoze.who identifier plugin. It is aimed at replacing repoze.who.plugins.auth_tkt in order to store the user data in beaker session.

The plugin stores a dictionary containing at least {'repoze.who.userid': userid} under key repoze.who.tkt.

UseBeakerPlugin takes the following parameters:

  • key_name (default: repoze.who.tkt) - the key name to store the userid under:

    >>> userid = session['repoze.who.tkt']
    
  • session_name (default: beaker.session) - the key name of the beaker session in the WSGI environment:

    >>> session = environ['beaker.session']
    
  • delete_on_logout (default: false) - if false then on logout session['repoze.who.tkt'] is erased but the other session data stays and will be reused during the next session. If you want the session to be invalidated pass delete_on_logout = True

  • alsopersist (default: ['userdata']) - a sequence of item keys that are persisted along to repoze.who.userid

Usually you should use make_plugin method instead of instantiating UseBeakerPlugin directly:

>>> from repoze.who.plugins.use_beaker import make_plugin
>>> plugin = make_plugin(**kw)

In order to properly use the beaker.session repoze.who (with repoze.who-use_beaker) has to be placed lower in the WSGI stack. Usually this means that you have to define repoze.who in your framework's middleware configuration higher than beaker session. E.g. (using the factory from repoze.what-quickstart):

>>> from beaker.middleware import SessionMiddleware
>>> from repoze.what.plugins.quickstart import setup_sql_auth
>>> from repoze.who.plugins.use_beaker import make_plugin as make_beaker_plugin

... # app definition here

>>> app = setup_sql_auth(app,
...     User, Group, Permission, DBSession,
...     # HERE we provide the beaker plugin to be used as the primary identifier
...     identifiers=[('use_beaker', make_beaker_plugin())],
...     form_plugin=... # The rest of repoze configuration

... # more middlewares here

>>> app = SessionMiddleware(app, config)

Git repository is located at GitHub.com.

repoze.who-use_beaker's People

Contributors

akissa avatar lmctv avatar markstuart avatar

Stargazers

Brook Elgie avatar Howard Mei avatar  avatar Linas Juškevičius avatar Bo XIAO avatar Damilare Onajole avatar

Watchers

James Cloos avatar

repoze.who-use_beaker's Issues

When no session exists other IIdentifers can not be run.

When no session exists other IIdentifers can not be run due to
the exception. I chnaged Identity to return None if no session exists.

def identify(self, environ):
"""Return identity from Beaker session"""
try:
s = self._get_beaker(environ)
userid = s.get(self.key_name, None)
if userid:
return {'repoze.who.userid': userid}
except ValueError:
return None

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.