Code documentation

pyramid_persona Package

pyramid_persona.includeme(config)

Include persona settings into a pyramid config.

This function does the following:

  • Setup default authentication and authorization policies, and a default session factory. Keep in mind that the sessions are not encrypted, if you need to store secret information in it, please override the session factory.

  • Add two request attributes :
    • persona_js, the javascript code to inclue on a page to make persona work.
    • persona_button, the html for a default login/logout button.
  • Set login and logout views for use with persona.

  • Set a forbidden view with a loggin button

views Module

pyramid_persona.views.forbidden(request)

A basic 403 view, with a login button

pyramid_persona.views.login(request)

View to check the persona assertion and remember the user

pyramid_persona.views.logout(request)

View to forget the user

pyramid_persona.views.verify_login(request)

Verifies the assertion and the csrf token in the given request.

Returns the email of the user if everything is valid, otherwise raises a HTTPBadRequest

utils Module

pyramid_persona.utils.button(request)

If the user is logged in, returns the logout button, otherwise returns the login button

pyramid_persona.utils.js(request)

Returns the javascript needed to run persona