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.3.tar.gz
.
File metadata
- Download URL: rest_api_auth_manager-1.0.3.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 | cf08872a9c47b4cbed66ec651c6ca01d76f6208577d6cff2ee7512b2026ee5fb |
|
MD5 | 673c6694bf2c8dd32d57925cd26449c6 |
|
BLAKE2b-256 | af81cab512ca2fbbdca6309336cfb616e1dddf0780d425d4ca269b611e8cf9fb |
File details
Details for the file rest_api_auth_manager-1.0.3-py3-none-any.whl
.
File metadata
- Download URL: rest_api_auth_manager-1.0.3-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 | 097e16f0de079d71ee6790545f5e6e14e01c1e0e1c16bd3fbf0a9de7b285d9d1 |
|
MD5 | b9573cfe1f195afd8c393eb4bbe1c71e |
|
BLAKE2b-256 | 2bb906e490144364dc1dbacf50fe68da01dd7f3e4fd43a5a7aab3a9f82921ef9 |