Skip to main content

Simple Python library for Phlow authentication

Project description

Phlow Logo

Phlow

JWT authentication middleware for AI agents with Supabase integration

PyPI version License: MIT

๐ŸŽฏ What is Phlow?

Phlow is authentication middleware for AI agents that's evolving into the Agent Marketplace Platform - enabling agents to discover, authenticate, and monetize their capabilities.

Current: A2A Protocol + Supabase โ€ข JWT Auth โ€ข Middleware Vision: The "App Store for AI Agents"

๐ŸŒŸ Our Evolution Path

Phase 1: Authentication Middleware (Current)
   โ†“
Phase 2: Agent Discovery & Registry
   โ†“
Phase 3: Agent Marketplace Platform

We're building the foundational trust layer that will enable agents to securely discover, interact with, and monetize their capabilities - creating the first true marketplace for AI agent services.

โšก Quick Start

pip install phlow

Python Example

from phlow import PhlowMiddleware, AgentCard, PhlowConfig

config = PhlowConfig(
    agent_card=AgentCard(
        name="My Agent",
        description="Agent description",
        service_url="https://my-agent.com",
        skills=["chat", "analysis"],
        metadata={"agent_id": "my-agent-id", "public_key": "public-key-here"}
    ),
    private_key=os.environ["PRIVATE_KEY"],
    supabase_url=os.environ["SUPABASE_URL"],
    supabase_anon_key=os.environ["SUPABASE_ANON_KEY"]
)

phlow = PhlowMiddleware(config)

FastAPI Middleware

# Use A2A authentication with Supabase features
@app.post("/api/chat")
async def chat_endpoint(context: PhlowContext = Depends(auth_required)):
    # Access agent info and Supabase client
    agent = context.agent
    return {"message": f"Hello from {agent.name}"}

Full Setup Guide โ†’

๐Ÿš€ Features

  • ๐Ÿ” JWT Authentication - Verify A2A Protocol JWT tokens
  • ๐Ÿ“‹ Agent Storage - Store and retrieve agent cards in Supabase
  • ๐Ÿ›ก๏ธ RLS Helpers - Generate basic Supabase Row Level Security policies
  • ๐Ÿ“Š Basic Audit - Log authentication events to Supabase
  • ๐ŸŒ Python Package - Pure Python implementation
  • ๐Ÿ”ง FastAPI Integration - Complete middleware with dependency injection

How It Works

sequenceDiagram
    participant A as Agent A
    participant B as Agent B
    participant S as Supabase Registry

    A->>A: Generate JWT with private key
    A->>B: Send request + JWT + Agent ID header
    B->>S: Lookup Agent A's public key
    S->>B: Return AgentCard with public key
    B->>B: Verify JWT signature
    B->>A: Return response

๐Ÿ“ฆ What's Included

phlow/
โ”œโ”€โ”€ src/phlow/              # Python authentication library
โ”œโ”€โ”€ tests/                  # Test suite
โ”œโ”€โ”€ examples/               # Example implementations
โ””โ”€โ”€ docs/                   # Documentation
    โ”œโ”€โ”€ getting-started.md      # Quick setup guide
    โ”œโ”€โ”€ a2a-compatibility.md    # A2A Protocol integration
    โ””โ”€โ”€ api-reference.md        # API documentation

๐Ÿ—๏ธ How It Works

Phlow is a lightweight middleware that connects A2A Protocol JWT authentication with Supabase storage:

  1. JWT Verification - Validates A2A Protocol tokens
  2. Agent Lookup - Retrieves agent cards from Supabase
  3. Context Creation - Provides agent info and Supabase client to your app
  4. Basic Logging - Optionally logs auth events

See Getting Started for setup instructions.

๐Ÿ”ง Setup

  1. Install: pip install phlow
  2. Configure: Set up Supabase project and environment variables
  3. Initialize: Register your agent card in Supabase
  4. Authenticate: Add Phlow middleware to your A2A agent

Detailed Setup Instructions โ†’

๐Ÿ’ก Example: A2A Agent with Phlow Auth

# A2A + Phlow Integration
from phlow import PhlowMiddleware, AgentCard, PhlowConfig

config = PhlowConfig(
    agent_card=AgentCard(
        name="My Agent",
        description="A2A-compatible agent",
        service_url="https://my-agent.com",
        skills=["chat", "analysis"],
        metadata={"agent_id": "my-agent-id", "public_key": "public-key-here"}
    ),
    private_key=os.environ["PRIVATE_KEY"],
    supabase_url=os.environ["SUPABASE_URL"],
    supabase_anon_key=os.environ["SUPABASE_ANON_KEY"]
)

phlow = PhlowMiddleware(config)

# Use with FastAPI
from phlow.integrations.fastapi import create_phlow_dependency
auth_required = create_phlow_dependency(phlow)

@app.post("/api/a2a/message")
async def handle_message(context: PhlowContext = Depends(auth_required)):
    # Process A2A message using phlow context
    return {"status": "received"}

๐Ÿ“š Documentation

๐ŸŒ Language Support

Language Package Framework Support
Python phlow FastAPI

๐Ÿš€ Roadmap & Vision

Phase 1: Authentication Middleware (Current)

  • โœ… JWT authentication for A2A Protocol
  • โœ… Agent card storage in Supabase
  • โœ… Basic middleware for FastAPI
  • ๐Ÿ”„ Enhanced security and testing

Phase 2: Agent Discovery & Registry (Next 6 months)

  • ๐ŸŽฏ Central agent registry with search capabilities
  • ๐ŸŽฏ Agent capability matching and discovery
  • ๐ŸŽฏ Enhanced agent profiles and metadata
  • ๐ŸŽฏ Agent network visualization

Phase 3: Agent Marketplace Platform (6-18 months)

  • ๐ŸŽฏ Agent monetization and billing
  • ๐ŸŽฏ Usage analytics and performance metrics
  • ๐ŸŽฏ Agent rating and reputation systems
  • ๐ŸŽฏ Developer tools and SDK ecosystem

Our North Star: Create the first true marketplace where AI agents can discover, authenticate, and monetize their capabilities - making agent-to-agent commerce as simple as an API call.

Contributing

Pull requests welcome! We're building towards our marketplace vision:

Current Focus Areas:

  • Authentication middleware improvements
  • Supabase integration enhancements
  • Agent registry and discovery features
  • Developer experience improvements

Future Contribution Areas:

  • Agent marketplace features
  • Monetization and billing systems
  • Analytics and metrics
  • Community tools and governance

Scope: Please keep contributions focused on authentication, agent registry, discovery, and marketplace features. Communication protocols should be contributed to the A2A Protocol directly.

Quick Start

# Install dependencies
uv sync --dev

# Run all quality checks
uv run task quality

# Run tests
uv run task test

# Run E2E tests (requires Docker)
uv run task test-e2e

Development Commands

uv sync --dev              # Install all dependencies
uv run task test           # Run all tests with coverage
uv run task test-unit      # Run unit tests only
uv run task test-e2e       # Run end-to-end tests (Docker required)
uv run task lint           # Run linting with auto-fix
uv run task format         # Format code
uv run task type-check     # Run type checking
uv run task quality        # Run all quality checks
uv run task build          # Build distribution packages
uv run task clean          # Clean build artifacts

Testing

  • Unit Tests: uv run task test-unit - Fast, mocked, runs in CI
  • E2E Tests: uv run task test-e2e - Full stack, Docker required

License

MIT License - see LICENSE file for details.


Built with โค๏ธ for the A2A ecosystem

Get Started | A2A Compatibility | API Reference

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-0.1.6.tar.gz (62.8 kB view details)

Uploaded Source

Built Distribution

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

phlow-0.1.6-py3-none-any.whl (49.5 kB view details)

Uploaded Python 3

File details

Details for the file phlow-0.1.6.tar.gz.

File metadata

  • Download URL: phlow-0.1.6.tar.gz
  • Upload date:
  • Size: 62.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.4

File hashes

Hashes for phlow-0.1.6.tar.gz
Algorithm Hash digest
SHA256 c6bb1db3b7c13bc7eb2d5957c70ec7d07b80d708a22cf1661ce7af5b94ec68ec
MD5 672150392fcc98a80019df1df2547781
BLAKE2b-256 90acdd487ee1f3b7f0defe4f4009a94f9c7414b47c74e35dab2f3f5a2509ef9e

See more details on using hashes here.

File details

Details for the file phlow-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: phlow-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 49.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.4

File hashes

Hashes for phlow-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 03ac7492b833c1204afd8816a82137444a96996cdec67d1d2baf332cf20934bc
MD5 251c14e30101aa1dd416a86da53aaf5a
BLAKE2b-256 a20e5dd9fc629ad9a90c73f7b7261be6dd657a9b6888350a7e9aae5cd93e9b89

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