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
Built Distribution
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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4a5ea73f220723c7ba16d223d93792bb4a566b12d6e18e61f8e376a5b93371c0 |
|
MD5 | 1eed3678702a7649b7345c1b3dd18600 |
|
BLAKE2b-256 | 3b7d7f54803588f515c2bb1d92ac6a038e179b023685150823963f6f69479303 |
File details
Details for the file rest_api_auth_manager-1.0.4-py3-none-any.whl
.
File metadata
- Download URL: rest_api_auth_manager-1.0.4-py3-none-any.whl
- Upload date:
- Size: 5.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.16
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1dbf4c9930a960835a6fb08a6e50b489d10407c929009f1d440f291a7f7e8f1b |
|
MD5 | e2cfc3be7d2b653ba47d5d62137200a8 |
|
BLAKE2b-256 | 512d35060db8cca9167aa6bbde8111ca451b7b7634f4711ee2851a7ce51ec675 |