Skip to main content

Basic framework to handle authentication and authorization in any kind of Python application.

Project description

Build pypi versions license codecov

GuardPost

GuardPost provides a basic framework to handle authentication and authorization in any kind of Python application.

pip install guardpost

To install with support for JSON Web Tokens (JWTs) validation:

pip install guardpost[jwt]

This library is freely inspired by authorization in ASP.NET Core; although its implementation is extremely different.

Notable differences are:

  1. GuardPost is abstracted from the code that executes it, so it's not bound to the context of a web framework.
  2. GuardPost implements both classes for use with synchronous code (not necessarily I/O bound), and classes using async/await syntax (optimized for authentication and authorization rules that involve I/O bound operations such as web requests and communications with databases).
  3. GuardPost leverages Python function decorators for the authorization part, so any function can be wrapped to be executed after handling authorization.
  4. The code API is simpler.

More documentation and examples

For documentation and examples, refer to the project Wiki.

To see how guardpost is used in blacksheep web framework, read the documentation here:

Both for async/await and synchronous code

GuardPost can be used both with async/await code and with synchronous code, according to use cases and users' preference.

If you have doubts about authentication vs authorization...

Authentication answers the question: Who is the user who is executing the action?, or more in general: Who is the user, or what is the service, that is executing the action?.

Authorization answers the question: Is the user, or service, authorized to do something?.

Usually, to implement authorization, is necessary to have the context of the entity that is executing the action. Anyway, the two things are logically separated and GuardPost is designed to keep them separate.

Usage in BlackSheep

guardpost is used in the BlackSheep web framework to implement authentication and authorization strategies for request handlers.

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

guardpost-0.0.8.tar.gz (13.4 kB view details)

Uploaded Source

Built Distribution

guardpost-0.0.8-py3-none-any.whl (16.8 kB view details)

Uploaded Python 3

File details

Details for the file guardpost-0.0.8.tar.gz.

File metadata

  • Download URL: guardpost-0.0.8.tar.gz
  • Upload date:
  • Size: 13.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for guardpost-0.0.8.tar.gz
Algorithm Hash digest
SHA256 0b3d0a5c1407e7ada7bb92c78a2f625e13c88ae7a6408d196d05c98f44871432
MD5 12f0949fd2c2d41e6e3f79a56752b2c9
BLAKE2b-256 01230ef2eb5e4cd71fb0024c054c9365512b31fd06434c26004693430aae1816

See more details on using hashes here.

File details

Details for the file guardpost-0.0.8-py3-none-any.whl.

File metadata

  • Download URL: guardpost-0.0.8-py3-none-any.whl
  • Upload date:
  • Size: 16.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for guardpost-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 f1a5fcbbf6188c6e8dc57a09a8753b347547b73de5f525eec8bb5ccbd15e1333
MD5 8a30fd41791f9b7efe93ae17de16e8c7
BLAKE2b-256 df2de9120433469c25acb5189b87a82c52cbd9996f83666c59c65ad693cb2bcb

See more details on using hashes here.

Supported by

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