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.
pip install rest_api_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)
user = {
"alias": "ASH_KETCHUM",
"name": "Ash Ketchum",
"email": "[email protected]",
"roles": ["pokemons:get"],
}
token = auth_manager.add_user(user)
auth_manager.add_role_to_user("ASH_KETCHUM", "pokemons:post")
token = "SUPER_SECRET"
auth_manager.verify_auth(token, "api/pokemon", "GET")