Tokenly-Auth
Tokenly-Auth is a professional-grade, database-agnostic authentication and session management utility library for Python. It provides high-level security primitives without enforcing any specific database ORM or model structure, giving you total flexibility.
Core Features
- Crypto Utilities: Argon2id password hashing and verification with brute-force protection logic.
- Token Management: JWT creation and verification.
- Session Utilities: Secure refresh token hashing for rotation strategies.
- Middleware: Storage-agnostic rate limiting and authentication decorators.
- Validation: Strict structural validation for usernames and passwords.
- Lightweight: No dependency on SQLModel, Pydantic, or any specific database driver.
Installation
pip install tokenly-auth
Quick Start
1. Password Hashing
from tokenly_auth import Security
# Hash a password
hashed = Security["hash"]("my_secure_password")
# Verify a password
is_valid = Security["verify"]("my_secure_password", hashed)
# Reset logic (Verify old -> Hash new)
new_hash = Security["reset"](hashed, "old_password", "new_password")
2. JWT & Tokens
from tokenly_auth import TokenHandler, SessionManager
handler = TokenHandler(SECRET_KEY="your_secret_key")
# Create Access & Refresh tokens
tokens = handler.createJwt(sub="user_id_123")
# Returns: {"access_token": "...", "refresh_token": "...", "refresh_days": 7}
# Hash refresh token for secure storage
session_util = SessionManager()
storage_hash = session_util.hash_refresh_token(tokens["refresh_token"])
3. Middleware & Protection
from tokenly_auth import require_auth, TokenHandler
handler = TokenHandler(SECRET_KEY="your_secret_key")
@require_auth(jwt_handler=handler)
def protected_route(payload):
return f"Hello {payload['sub']}"
Architecture: Why "Database Agnostic"?
Unlike other libraries that force you to use a specific ORM (like SQLAlchemy or SQLModel), Tokenly-Auth acts as a security toolkit.
- You control the database (PostgreSQL, MongoDB, Redis, etc.).
- You control the models.
- Tokenly-Auth handles the heavy lifting of hashing, signing, and security logic.
Testing
pytest
License
MIT License.
Metadata
Release files for tokenly-auth 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| tokenly_auth-1.0.0.tar.gz | 10.8 kB | Without provenance | Details for tokenly_auth-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| tokenly_auth-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for tokenly_auth-1.0.0-py3-none-any.whl |
Total release size: 21.8 kB
Release files / tokenly_auth-1.0.0.tar.gz
| Download URL | tokenly_auth-1.0.0.tar.gz |
|---|---|
| Size | 10.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
dbfc91da33ac35cf148dea4d54e91b0d6072a8157571ce60f7777244300d7552
|
|
BLAKE2b-256 checksum How to use checksums |
f13cdc50bcbaf9d368604ac9658a95245b908cc00cdd4f15b1d2c1c8bab959a5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.20
|
Release files / tokenly_auth-1.0.0-py3-none-any.whl
| Download URL | tokenly_auth-1.0.0-py3-none-any.whl |
|---|---|
| Size | 11.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3f5e875425499b8c2e33b7477f438ca3a87c2e7b19870b5a37b6a38ce6a6054e
|
|
BLAKE2b-256 checksum How to use checksums |
87557ce3297c41a2b67d3d5cae2ab6e796317dc4aa0095805949dbdaabf72067
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.10.20
|
Security for tokenly-auth 1.0.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.