Skip to main content

Strong, Simple, and Precise security for Sanic APIs

Project description

Latest Published Version Build Testing Status Supported Python versions Documentation Build Status Codecov Report https://static.pepy.tech/personalized-badge/sanic-beskar?period=total&units=international_system&left_color=grey&right_color=orange&left_text=Downloads Codacy Badge Interrogate Badge Security Status Code style: black

sanic-beskar

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

sanic_beskar-3.1.0.post1.tar.gz (34.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sanic_beskar-3.1.0.post1-py3-none-any.whl (38.5 kB view details)

Uploaded Python 3

File details

Details for the file sanic_beskar-3.1.0.post1.tar.gz.

File metadata

  • Download URL: sanic_beskar-3.1.0.post1.tar.gz
  • Upload date:
  • Size: 34.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.4 CPython/3.11.15 Linux/6.17.0-1015-azure

File hashes

Hashes for sanic_beskar-3.1.0.post1.tar.gz
Algorithm Hash digest
SHA256 87547dc2a67e667ad8f90fcc7454788ad4215c48dcede5b8cee27c242d962808
MD5 9038263e59bc161866c6c1dab9457205
BLAKE2b-256 d934e4d03e3a41dbca1875022855577c6d13b12542ae7f95318c024122a238c1

See more details on using hashes here.

File details

Details for the file sanic_beskar-3.1.0.post1-py3-none-any.whl.

File metadata

  • Download URL: sanic_beskar-3.1.0.post1-py3-none-any.whl
  • Upload date:
  • Size: 38.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.3.4 CPython/3.11.15 Linux/6.17.0-1015-azure

File hashes

Hashes for sanic_beskar-3.1.0.post1-py3-none-any.whl
Algorithm Hash digest
SHA256 007d901c8b82bb1cae2f938c6b7e72627370185630bafc42dfa0f575772d395b
MD5 3494909742f071b76a15c84bca201652
BLAKE2b-256 ed9294402bf7d253d281da1595f315929fe40a41eae089273f1e77897c404402

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page