Version: v1.2.3 | Status: Stable | Last Updated: March 2026
The auth module handles authentication and authorization within Codomyrmex. It manages API keys, token generation, and permissions checks.
authenticate(credentials: dict) -> Optional[Token]: Verify credentials and issue a token.authorize(token: Token, resource: str, permission: str) -> bool: Check if a token allows a specific action.get_authenticator() -> Authenticator: Get the main authenticator instance.
Authenticator: Central logic for auth flows.Token: Data structure representing an authenticated session.TokenManager: Handles token lifecycle and validation.APIKeyManager: CRUD operations for API keys.
AuthenticationError: Raised on login failure or invalid token.
from codomyrmex.auth import authenticate, authorize
# Login
token = authenticate({"api_key": "sk_12345"})
# Check permission
if authorize(token, "database", "read"):
print("Access granted")