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"
    token_length = 16

auth_manager = AuthManager(CustomConfig)

Add new user

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

token = auth_manager.add_user(user)

Granting usage on a specific resource

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

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.4.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: rest_api_auth_manager-1.0.4.tar.gz
  • Upload date:
  • Size: 4.9 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.4.tar.gz
Algorithm Hash digest
SHA256 4a5ea73f220723c7ba16d223d93792bb4a566b12d6e18e61f8e376a5b93371c0
MD5 1eed3678702a7649b7345c1b3dd18600
BLAKE2b-256 3b7d7f54803588f515c2bb1d92ac6a038e179b023685150823963f6f69479303

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for rest_api_auth_manager-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 1dbf4c9930a960835a6fb08a6e50b489d10407c929009f1d440f291a7f7e8f1b
MD5 e2cfc3be7d2b653ba47d5d62137200a8
BLAKE2b-256 512d35060db8cca9167aa6bbde8111ca451b7b7634f4711ee2851a7ce51ec675

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