Skip to main content

Simple manager for REST API authentication and authorization (token based)

Project description

rest-api-simple-auth-manager

Simple REST API authentication and authorization manager, designed to operate with token-based security. This package is intended to act as a middleware, providing a secure method for verifying user credentials before granting access to the requested resource.

The current implementation relies on a Redis instance to store and manage credentials. However, we are working on integrating other database options to offer more flexibility and customization.

Install

pip install rest_api_auth_manager

Initializing the auth manager

from rest_api_auth_manager import AuthManager, Config

class CustomConfig(Config):
    credentials_database_host = "127.0.0.1"
    environment = "dev"
    password_length = 16

auth_manager = AuthManager(CustomConfig)

Add new user

user = {
    "alias": "ASH_KETCHUM",
    "name": "Ash Ketchum",
    "email": "ash@test.com",
    "roles": [],
}

token = auth_manager.add_user(user)

Granting usage on a specific resource

auth_manager.add_role_to_user("ASH_KETCHUM", "pokemons:get")

Verifying requests authentication and authorization

token = "SUPER_SECRET"
auth_manager.verify_auth(token, "api/pokemon", "GET")

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

rest_api_auth_manager-1.0.2.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

rest_api_auth_manager-1.0.2-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

Details for the file rest_api_auth_manager-1.0.2.tar.gz.

File metadata

  • Download URL: rest_api_auth_manager-1.0.2.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.9.16

File hashes

Hashes for rest_api_auth_manager-1.0.2.tar.gz
Algorithm Hash digest
SHA256 afb650e1efb87a4d2cbbaa6c6a1c03aa9064fe868a08335991bde6f1215cb916
MD5 dddc9dc4b2b19af72d6c67e8c6131ec9
BLAKE2b-256 86d4eec126b52f48f5f04e5abace6fabfe08b94d68aff7acee7b7799e1815351

See more details on using hashes here.

File details

Details for the file rest_api_auth_manager-1.0.2-py3-none-any.whl.

File metadata

File hashes

Hashes for rest_api_auth_manager-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 87e60b8477c7fc14a0256ce8555395cc735d04e6dfd01f871d251607d172a22f
MD5 822813d6ab63e7bad0f6b404ea626d22
BLAKE2b-256 e659555266b59fca2c8877970738232a1bb6b639da8c18c06641fb2255428a36

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