Skip to main content

pyramid_persona

Project description

pyramid_persona let you quickly set up authentication using persona on your pyramid project. It provides a way to conveniently replace the login form and all the processing and security concerns that comes with it. It aims at giving as much as possible with as little configuration as possible, while still letting you customize if you want. If you want to see some screenshots of the demo app, take a look at this blog post.

You can find it on pypi as pyramid_persona. Also don’t forget to check the documentation.

Very basic usage

First of all, include pyramid_persona. Add this in your project configuration

config.include("pyramid_persona")

Then, we need two little lines in your config files : a secret used to sign cookies, and the audience, the hostname and port of your website (this is needed for security reasons):

persona.secret = This is some secret string
persona.audiences = http://localhost:6543

There, we’re done. We now have a nice forbidden view with a persona login button.

Less basic usage

pyramid_persona also provides you a way to easily put a login or logout button on your pages. To do so, you need to include jquery, the persona library, and some application-specific in your heads. The application specific javascript can be accessed as request.persona_js.

Then, you can add the button in your page. request.persona_button provides a login if the user is not logged in, and a logout button if they are.

A basic page might be (using mako)

<html>
<head>
    <script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
    <script src="https://login.persona.org/include.js" type="text/javascript"></script>
    <script type="text/javascript">${request.persona_js}</script>
</head>
<body>
Hello ${user}
${request.persona_button}
</body>
</html>

Customized buttons

You can also use your own buttons. For that, you have to include the javascript like in the previous section and give your login and logout button the signin and signout classes. For example

<button id='signin'>login</button>
<button id='signout'>logout</button>

What it does

pyramid_persona is a login system. It replaces login forms and views, and the need to handle passwords.

pyramid_persona is not an authentication policy. It only handles the login process and requires an authentication policy to remember the user between requests (SessionAuthenticationPolicy is used by default).

Here is, in details, what including pyramid_persona does :

  • it defines an authentication policy, an authorization policy, and a session factory (this is needed for csrf protection, and is why we need a secret). Defaults are SessionAuthenticationPolicy, ACLAuthorizationPolicy and UnencryptedCookieSessionFactoryConfig. You can override it if you prefer.

  • it adds a persona_js request attribute containing the javascript code needed to make persona work.

  • it adds a persona_button request attribute containing html code for quickly putting a login button.

  • it defines the /login and /logout views to handle the persona workflow.

  • it defines a basic forbidden view with a login button.

You can replace any part you like if the default behaviour doesn’t work for you and the configuration isn’t enough.

Contact

This project is made by Georges Dubus (@georgesdubus). Bug reports and pull requests are welcome.

1.5

  • Added success to the login view response, to state whether the login attempt was successful, and whether the user should be considered as logged-in.

  • Added support for the new backgroundColor option, to change the color of the login dialog.

1.4

  • Changed the login views and the javascript code to implemente mozilla recommended practices. logout is now called after an error in the login view, and the format of the login view has changed.

1.3.1

  • Made all views not required any permission even if a default permission is set.

1.3

  • Depends on pyramid 1.4

  • Added some real docs

  • Added documentation on how to do extra work at login, and made the internal changes for it to work.

  • Added logging in case of failed login.

  • Switched to a AuthTktAuthenticationPolicy so that the login doesn’t expire with the session.

1.2

  • Fixed a bug that would cause the login to fail when the login route was not at ‘/login’.

1.1

  • Added an example app in demo/.

  • Fixed compatibility with pyramid 1.3.

  • Renamed the setting persona.audience to persona.audiences to match the PyBrowserID API.

  • Added the “persona.verifier” setting to change the verifier.

  • Added various settings to customize the login dialog.

  • Compatibility with python 3.

1.0

  • Initial version

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyramid_persona-1.5.tar.gz (8.6 kB view details)

Uploaded Source

Built Distribution

pyramid_persona-1.5-py2.py3-none-any.whl (11.8 kB view details)

Uploaded Python 2Python 3

File details

Details for the file pyramid_persona-1.5.tar.gz.

File metadata

  • Download URL: pyramid_persona-1.5.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for pyramid_persona-1.5.tar.gz
Algorithm Hash digest
SHA256 8dbee47bec0fc9345093a64c8a1a9220891b096a3becae8c9c6cd6edc3cdf6f5
MD5 ae67772f3b8e8ce27efb97f19ea42756
BLAKE2b-256 81469e4da1ca71253915f734c5937e755d4f94c411648efd77b58c4be14a0213

See more details on using hashes here.

File details

Details for the file pyramid_persona-1.5-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for pyramid_persona-1.5-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 462027301c48931e9a575cc75fd8f416ccf7c377f98e5634c1e6650bb0d3860a
MD5 76cf36d2a593bf49795d11942b93afd4
BLAKE2b-256 251322ae5a06e959411eb96c22f0c371b2b0fcf8e1d7acef2c5e94699d955bbd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page