rivr-jwt

Making authentication with JWT (JSON Web Token) and rivr simple.


License
BSD-3-Clause
Install
pip install rivr-jwt==0.3.0

Documentation

rivr-jwt

A library for using JSON Web Tokens (JWT) for authentication with rivr.

Installation

$ pip install rivr-jwt

Usage

rivr-jwt provides a middleware which can automatically verify JSON Web Tokens from both cookies and Authorization headers, the JWT payload will be available as jwt on the request object passed though the JWT middleware.

middleware = JWTMiddleware(key='secret', algorithms=['HS256'])

Using a JWT from a Cookie or Authorization header

def view(request):
    if request.jwt and 'username' in request.jwt:
        username = request.jwt['username']
        return Response('Hello {}'.format(username))

    return Response('Hello world')

Setting JWT as a cookie

You can set jwt_cookie on a response for it to be encoded as a cookie.

def view(request):
    response = Response('Hello World')
    response.jwt_cookie = {'username': 'Kyle'}
    return response

License

rivr-rest is released under the BSD license. See LICENSE.