Non-blocking security: Asynchronous secret management with asyncio.
Synchronous database and crypto calls are the hidden concurrency killers in FastAPI microservices. wauth provides native async_set, async_get, and async_valid to keep your event loop running at full speed.
Here is the exact production implementation for Asynchronous API (async_set, async_get, async_valid):
import asyncio
from wauth import WAuth
auth = WAuth()
async def authenticate_request(api_key: str) -> bool:
# Non-blocking, constant-time verification in async coroutine
is_valid = await auth.async_valid("SERVICE_API_KEY", api_key)
return is_valid
async def main():
await auth.async_set("SERVICE_API_KEY", "sk_live_994821")
authorized = await authenticate_request("sk_live_994821")
print(f"Request authorized: {authorized}")
asyncio.run(main())
Why this changes developer velocity:
-
Native Async Methods:
async_set(),async_get(),async_delete(), andasync_valid(). - FastAPI Optimized: Drop directly into async route dependencies with zero event loop stalling.
- Thread-Pool Delegated: Cryptographic computations are safely offloaded without blocking I/O.
Zero Pain:
- Synchronous database queries and crypto calls blocking the event loop in async microservices
- Slow request handling in FastAPI endpoints that frequently verify user API keys
- Concurrency bottlenecks when hundreds of concurrent coroutines query secrets simultaneously
Explore the verified open-source repository on GitHub or install it via:
pip install wauth
Top comments (0)