anseljh / falcon-auth

A falcon middleware + authentication backends that adds authentication layer to you app/api service.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

falcon-auth

version Documentation Status build coverage license

A falcon middleware + authentication backends that adds authentication layer to you app/api service.

Installation

Install the extension with pip, or easy_install.

If you wish to use the optional backends, specify those dependencies, too.

Usage

This package exposes a falcon middleware which takes an authentication backend as an input and use it to authenticate requests. You can specify some routes and methods which are exempted from authentication. Once the middleware authenticates the request using the specified authentication backend, it add the authenticated user to the request context

Override Authentication for a specific resource

Its possible to customize the exempt routes, exempt methods and authentication backend on a per resource basis as well

Disable Authentication for a specific resource

Accessing Authenticated User

Once the middleware authenticates the request using the specified authentication backend, it add the authenticated user to the request context

Authentication Backends

  • Basic Authentication

Implements HTTP Basic Authentication wherein the HTTP Authorization header contains the user credentials(username and password) encoded using base64 and a prefix (typically Basic)

  • Token Authentication

Implements a Simple Token Based Authentication Scheme where HTTP Authorization header contains a prefix (typically Token) followed by an API Token

  • JWT Authentication (Python 2.7, 3.4+)

Token based authentication using the JSON Web Token standard If you wish to use this backend, be sure to add the optional dependency to your requirements (See Python "extras"):

falcon-auth[backend-jwt]
  • Hawk Authentication (Python 2.6+, 3.4+)

Token based authentication using the Hawk "Holder-Of-Key Authentication Scheme" If you wish to use this backend, be sure to add the optional dependency to your requirements (See Python "extras"):

falcon-auth[backend-hawk]
  • Dummy Authentication

Backend which does not perform any authentication checks

  • Multi Backend Authentication

A Backend which comprises of multiple backends and requires any of them to authenticate the request successfully.

Tests

This library comes with a good set of tests which are included in tests/. To run install pytest and simply invoke py.test or python setup.py test to exercise the tests. You can check the test coverage by running py.test --cov falcon_auth

API

falcon_auth.FalconAuthMiddleware

falcon_auth.BasicAuthBackend

falcon_auth.TokenAuthBackend

falcon_auth.JWTAuthBackend

falcon_auth.NoneAuthBackend

falcon_auth.MultiAuthBackend

About

A falcon middleware + authentication backends that adds authentication layer to you app/api service.

License:MIT License


Languages

Language:Python 100.0%