JWT authentication middleware for AI agents with Supabase integration
Project description
Phlow Auth Python
JWT authentication middleware for AI agents with Supabase integration.
Installation
pip install phlow-auth
Quick Start
from phlow_auth import PhlowMiddleware, PhlowConfig, AgentCard
# Configure your agent
config = PhlowConfig(
supabase_url="https://your-project.supabase.co",
supabase_anon_key="your-anon-key",
agent_card=AgentCard(
name="My Agent",
description="AI assistant agent",
service_url="https://my-agent.com",
skills=["chat", "analysis"],
metadata={"agent_id": "my-agent-id", "public_key": "your-public-key"}
),
private_key="your-private-key"
)
# Initialize middleware
phlow = PhlowMiddleware(config)
# Use as decorator with FastAPI
from fastapi import FastAPI, Request
app = FastAPI()
@app.post("/api/chat")
@phlow.authenticate()
async def chat(request: Request):
# Access agent context
agent = request.phlow.agent
supabase = request.phlow.supabase
return {"message": f"Hello from {agent.name}"}
Features
- JWT Authentication - Verify A2A Protocol JWT tokens
- Agent Storage - Store and retrieve agent cards from Supabase
- RLS Helpers - Generate basic Row Level Security policies
- Event Logging - Track authentication events
- Multi-Framework - Works with FastAPI, Flask, and Django
Development
# Clone the repository
git clone https://github.com/prassanna-ravishankar/phlow.git
cd phlow/packages/phlow-auth-python
# Install development dependencies
uv sync --extra dev
# Run tests
uv run pytest
# Format code
uv run black src tests
uv run isort src tests
# Type checking
uv run mypy src
Documentation
- 📖 Documentation: https://prassanna.io/phlow/
- 🐛 Issues: https://github.com/prassanna-ravishankar/phlow/issues
- 💬 Discussions: https://github.com/prassanna-ravishankar/phlow/discussions
License
MIT License - see LICENSE file for details.
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
phlow_auth-0.0.5.tar.gz
(10.6 kB
view details)
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 phlow_auth-0.0.5.tar.gz.
File metadata
- Download URL: phlow_auth-0.0.5.tar.gz
- Upload date:
- Size: 10.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e5eacc17b2b2183106bca0a1829215870c1942dbb5cfebe5c562715146ec5604
|
|
| MD5 |
0953494c91a6e907d6b75958edce5778
|
|
| BLAKE2b-256 |
d1085ded9b9ff53cc2a0d3b85ef1f928467cba45d54a7b8ec5adeed9c53d1e28
|
File details
Details for the file phlow_auth-0.0.5-py3-none-any.whl.
File metadata
- Download URL: phlow_auth-0.0.5-py3-none-any.whl
- Upload date:
- Size: 13.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.11.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3aa4def66a491c8272d6f6f39b5b0a3c8e33e56777828612f7242ebc22f3e870
|
|
| MD5 |
ad62e05525689cdcf54bd028b42d4731
|
|
| BLAKE2b-256 |
9362b97800d061132bfb83361dd949e5a1f989839139887e901331f89801732b
|