Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/pahrohfit/sanic-beskar

Strong, Simple, and Precise, (and now async!) security for Sanic APIs
https://github.com/pahrohfit/sanic-beskar

authentication authorization python python3 sanic security

Last synced: 30 days ago
JSON representation

Strong, Simple, and Precise, (and now async!) security for Sanic APIs

Awesome Lists containing this project

README

        

.. image:: https://badge.fury.io/py/sanic-beskar.svg
:target: https://badge.fury.io/py/sanic-beskar
:alt: Latest Published Version

.. image:: https://github.com/pahrohfit/sanic-beskar/actions/workflows/main.yml/badge.svg
:target: https://github.com/pahrohfit/sanic-beskar/actions/workflows/main.yml
:alt: Build Testing Status

.. image:: https://img.shields.io/pypi/pyversions/sanic-beskar.svg
:target: https://img.shields.io/pypi/pyversions/sanic-beskar
:alt: Supported Python versions

.. image:: https://readthedocs.org/projects/sanic-beskar/badge/?version=latest
:target: http://sanic-beskar.readthedocs.io/en/latest/?badge=latest
:alt: Documentation Build Status

.. image:: https://codecov.io/gh/pahrohfit/sanic-beskar/branch/master/graph/badge.svg?token=24WAYX4OMT
:target: https://codecov.io/gh/pahrohfit/sanic-beskar
:alt: Codecov Report

.. image:: https://static.pepy.tech/personalized-badge/sanic-beskar?period=total&units=international_system&left_color=grey&right_color=orange&left_text=Downloads
:target: https://pepy.tech/project/sanic-beskar

.. image:: https://api.codacy.com/project/badge/Grade/55f9192c1f584ae294bc1642b0fcc70c
:alt: Codacy Badge
:target: https://app.codacy.com/gh/pahrohfit/sanic-beskar?utm_source=github.com&utm_medium=referral&utm_content=pahrohfit/sanic-beskar&utm_campaign=Badge_Grade_Settings

.. image:: docs/_static/interrogate_badge.svg
:alt: Interrogate Badge
:target: http://sanic-beskar.readthedocs.io/en/latest

.. image:: https://img.shields.io/badge/security-bandit-yellow.svg
:target: https://github.com/PyCQA/bandit
:alt: Security Status

.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
:target: https://github.com/psf/black
:alt: Code style: black

******************
sanic-beskar
******************

* Stable branch: `master `_
* CBTE (coding by trial and error) branch: `dev `_
* Working example(s): `examples/*.py `_

---------------------------------------------------
Strong, Simple, and Precise security for Sanic APIs
---------------------------------------------------

This project's beginning was fully lifted from the awesome
`Flask-Praetorian `_.

Why `beskar `_? Why not -- what
is better than star wars (provided you ignore the fact ~the mandolorian~
was almost as lame as ~book of boba fett~)?
Superior armour should be used if you want superior protection.

This package aims to provide that. Using token implemented by either
`PySETO `_ or
`PyJWT `_,
*sanic-beskar* uses a very simple interface to make sure that the users
accessing your API's endpoints are provisioned with the correct roles for
access.

The goal of this project is to offer simplistic protection, without
forcing nonsense, excessivly complicatated implementation, or
mandated/opinionated ORM usage. Providing this usability for small
scaled Sanic applications, while allowing the flexibility and
scalability for enterprise grade solutions, separates this from your
other options.

The *sanic-beskar* package can be used to:

* Hash passwords for storing in your database
* Verify plaintext passwords against the hashed, stored versions
* Generate authorization tokens upon verification of passwords
* Check requests to secured endpoints for authorized tokens
* Supply expiration of tokens and mechanisms for refreshing them
* Ensure that the users associated with tokens have necessary roles for access
* Parse user information from request headers for use in client route handlers
* Support inclusion of custom user claims in tokens
* Register new users using email verification
* Support OTP authentication as a dual factor
* Provide RBAC based protection of endpoints and resources

All of this is provided in a very simple to configure and initialize flask
extension. Though simple, the security provided by *sanic-beskar* is strong
due to the usage of the proven security technology of PASETO or JWT, along with
python's `PassLib `_ package.

Super-quick Start
-----------------
- requirements: `python` versions 3.7+
- install through pip: `$ pip install sanic-beskar`
- minimal usage example: `example/basic.py `_

Documentation
-------------

The complete documentation can be found at the
`sanic-beskar home page `_