Skip to main content

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

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)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

phlow_auth-0.0.5-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

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

Hashes for phlow_auth-0.0.5.tar.gz
Algorithm Hash digest
SHA256 e5eacc17b2b2183106bca0a1829215870c1942dbb5cfebe5c562715146ec5604
MD5 0953494c91a6e907d6b75958edce5778
BLAKE2b-256 d1085ded9b9ff53cc2a0d3b85ef1f928467cba45d54a7b8ec5adeed9c53d1e28

See more details on using hashes here.

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

Hashes for phlow_auth-0.0.5-py3-none-any.whl
Algorithm Hash digest
SHA256 3aa4def66a491c8272d6f6f39b5b0a3c8e33e56777828612f7242ebc22f3e870
MD5 ad62e05525689cdcf54bd028b42d4731
BLAKE2b-256 9362b97800d061132bfb83361dd949e5a1f989839139887e901331f89801732b

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page