A robust Python library for JWT, OAuth2, and database authentication.
Project description
Auth Plugin Library
Auth Plugin is a robust and flexible Python library designed to streamline the authentication process in web applications. It provides built-in support for JWT authentication, OAuth2 token management, and seamless database connectivity with MongoDB, PostgreSQL, and MySQL.
Features
- JWT Authentication: Easily encode and decode JSON Web Tokens (JWTs) with built-in error handling.
- OAuth2 Integration: Fetch and manage OAuth2 tokens with automatic error handling for HTTP requests.
- Database Connectivity: Connect to MongoDB, PostgreSQL, and MySQL databases with a simple API and proper connection management.
- Robust Error Handling: Comprehensive
try-except
blocks across all operations, ensuring stability and reliability. - Logging: Configurable logging for all operations, including JWT processing, OAuth2 token management, and database connections.
Installation
pip install auth-plugin
Usage
JWT Authentication
from auth_plugin.jwt_auth import JWTAuth
jwt_auth = JWTAuth(secret_key="your_secret_key")
token = jwt_auth.encode_token({"user_id": 123})
payload = jwt_auth.decode_token(token)
Database Management
from auth_plugin.db_manager import DBManager
# MongoDB
db_manager = DBManager(db_type="mongodb", host="localhost", port=27017, db_name="testdb")
# PostgreSQL
db_manager = DBManager(db_type="postgresql", user="username", password="password", host="localhost", port=5432, db_name="testdb")
# MySQL
db_manager = DBManager(db_type="mysql", user="username", password="password", host="localhost", db_name="testdb")
OAuth2 Authentication
from auth_plugin.oauth2_auth import OAuth2Auth
oauth2 = OAuth2Auth(client_id="your_client_id", client_secret="your_client_secret", token_url="https://example.com/oauth2/token")
access_token = oauth2.get_access_token(grant_type="client_credentials")
Documentation
Please refer to the official documentation for detailed usage instructions and examples.
Contributing
Contributions are welcome! Please check the contributing guidelines before submitting a pull request.
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 auth_plugin-0.2.2.0.tar.gz
.
File metadata
- Download URL: auth_plugin-0.2.2.0.tar.gz
- Upload date:
- Size: 4.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f6aa0b23bb22f07fd1b18477ec735cdc29b26ea3687aae44aeaba316092ce6cb |
|
MD5 | 4a7e47e6133d75c29d79abf2de57682d |
|
BLAKE2b-256 | 95d00aec6bfdbb5839fba2e179afa3f3485faef7f0674f9c79b471fda75683cb |
File details
Details for the file auth_plugin-0.2.2.0-py3-none-any.whl
.
File metadata
- Download URL: auth_plugin-0.2.2.0-py3-none-any.whl
- Upload date:
- Size: 7.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.12.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cae9c0fd2d2f59ae7c5ba83c2d78f824a21481b9d708a2484eccefe331ef076e |
|
MD5 | da1a6fa90799800665d21bf92eaa9af8 |
|
BLAKE2b-256 | 40068948e4c6e5282567cdfe59cb9186b04fa4deb8bc5cb6fdb4a024b3edcb71 |