Auth engine for EVOID — bring your own provider
Project description
evoid-auth
Bring-your-own-provider authentication — Intent Handler system
Quick Start • Intent Handler • Config • API
Quick Start
pip install evoid-auth
Method 1: Intent Handler (Recommended)
from evoid_auth import register_provider, register_handlers
from evoid.core.extend import before
# Register your auth logic
async def my_auth(token: str) -> dict:
user = await db.find_by_token(token)
if not user:
raise ValueError("Invalid token")
return {"user": user.name, "role": user.role}
register_provider("my_auth", my_auth)
# Register auth as Intent handlers
register_handlers()
# Wire to pipeline
before("GET:/users", "authenticate")
before("POST:/admin", "authenticate")
Method 2: Direct API
from evoid_auth import authenticate, authorize, register_provider
register_provider("jwt", jwt_auth_fn)
# authenticate and authorize are pipeline processors
Intent Handler
evoid-auth registers these Intent handlers:
| Intent | Handler | Description |
|---|---|---|
auth.authenticate |
authenticate |
Extract token, call provider, set user in ctx |
auth.authorize |
authorize |
Check role against requirement |
How it works
register_handlers()registers auth Intents as pipeline processorsauthenticateextracts token from request headers/metadata- Calls your registered provider function
- Writes
user,role,auth_methodtoctx.state authorizechecksctx.state["role"]against required roles
Token Sources
The authenticate processor checks these in order:
metadata["token"]— direct fieldAuthorization: Bearer <token>headerAuthorization: Token <token>headerX-API-Keyheader- Query parameter fallback
Role Hierarchy
admin (4) > editor (3) > viewer (2) > guest (1)
A higher role satisfies any lower requirement.
from evoid.core.extend import before
# Requires admin role
before("DELETE:/users", "authenticate", required_role="admin")
# Requires viewer or higher
before("GET:/reports", "authenticate", required_roles=["viewer", "editor", "admin"])
Configuration
TOML
[engines]
auth = "auth"
Python
from evoid_auth import register_provider
# Register multiple providers
register_provider("jwt", jwt_auth_fn)
register_provider("api_key", api_key_auth_fn)
# Use specific provider in pipeline
before("GET:/users", "authenticate", provider="jwt")
API
register_handlers()
Register auth as Intent handlers. No parameters needed.
Provider Registration
| Function | Signature | Description |
|---|---|---|
register_provider |
register_provider(name, fn) |
Register an auth provider |
resolve_provider |
resolve_provider(name) |
Get provider by name |
list_providers |
list_providers() |
List all registered names |
Processors
| Processor | Description |
|---|---|
authenticate |
Extracts token, calls provider, sets ctx.state |
authorize |
Checks role against requirement |
Provider Signature
async def my_provider(token: str) -> dict:
"""Must return dict with at least 'role' key."""
return {"user": "alice", "role": "admin"}
Dependencies
evoid>=0.4.0
Optional Dependencies
pyjwt>=2.8.0— for JWT decoding in your provider
Links
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file evoid_auth-0.1.0-py3-none-any.whl.
File metadata
- Download URL: evoid_auth-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
403e9e42a109ee2f3a04c573f4106c10e28e4b023451d0fe175c4d313b75dce1
|
|
| MD5 |
202c3675962363997c7919311380fc84
|
|
| BLAKE2b-256 |
5e7a6f1dfd43b7915638710f1133155ca044797dc549b1a256917395b5f9b491
|
Provenance
The following attestation bundles were made for evoid_auth-0.1.0-py3-none-any.whl:
Publisher:
publish-plugins.yml on EvolveBeyond/evoid-plugins
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
evoid_auth-0.1.0-py3-none-any.whl -
Subject digest:
403e9e42a109ee2f3a04c573f4106c10e28e4b023451d0fe175c4d313b75dce1 - Sigstore transparency entry: 2212593130
- Sigstore integration time:
-
Permalink:
EvolveBeyond/evoid-plugins@e70463a06d02a56a374ab215592e29eb027d6fac -
Branch / Tag:
refs/tags/0.1.1 - Owner: https://github.com/EvolveBeyond
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish-plugins.yml@e70463a06d02a56a374ab215592e29eb027d6fac -
Trigger Event:
push
-
Statement type: