A library for using JSON Web Tokens (JWT) for authentication with rivr.
$ pip install rivr-jwtrivr-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'])def view(request):
if request.jwt and 'username' in request.jwt:
username = request.jwt['username']
return Response('Hello {}'.format(username))
return Response('Hello world')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 responserivr-rest is released under the BSD license. See LICENSE.