A Library for Portier with asyncio
15 Feb 2017
In a previous post, I said:
Down the line, there will be client-side Portier libraries (or, at least, other demo implementations) for various languages. Until then, you’ll need to do some of the heavy lifting yourself.
Well, I decided to self-fulfill this prophecy. Introducing… the asyncio-portier Python library!
The asyncio-portier library works with Python 3.5 and up.
There’s a functioning demo included with the library which you can use as a template. I’ll go into more detail about it here.
If you’ve read the previous post, this should seem pretty familiar. There are a few important differences though; I’ll point them out along the way.
The login endpoint
cacheis a Redis connection object as from redis-py
self.audienceis the URL of your application (such as
broker_urlis the URL of the Portier Broker,
The primary difference here is in what we set in the Redis cache. We prepend
'portier:nonce:' to the nonce value used for the key, and we set
the value to the
next URL query parameter. With this, if the user visits a
page that requires authentication, the application can redirect them directly
to that page after they have logged in.
The verify endpoint
- You have a template for an error page named
get_verified_email function now takes a number of explicit parameters
instead of reading from a global
SETTINGS object. It can raise
RuntimeError. It also now returns a
next_page in addition to an
This library should make things a little bit easier for anyone using Portier and asyncio. Please let me know if you run into any issues!
Comments: View this post's comment section here.