Skip to main content

Agentic Profile Authentication Library

Project description

Agentic Profile Authentication

A Python library for handling authentication and verification of AI agent profiles using Decentralized Identifiers (DIDs).

Features

  • DID resolution for web, HTTP, and HTTPS methods
  • Challenge-response authentication flow
  • JWT-based attestation with EdDSA signatures
  • Configurable caching of resolved profiles
  • Async/await support for all operations
  • Type hints and Pydantic models for data validation

Installation

pip install agentic-profile-auth

Quick Start

from agentic_profile_auth import HttpDidResolver, InMemoryAgenticProfileStore

# Create a resolver with caching
store = InMemoryAgenticProfileStore()
resolver = HttpDidResolver(store=store)

# Resolve a DID
async def resolve_did():
    profile, metadata = await resolver.resolve("did:web:example.com")
    print(f"Resolved profile: {profile}")
    print(f"Resolution metadata: {metadata}")

# Handle authentication
from agentic_profile_auth import handle_authorization

async def authenticate_request(auth_header: str):
    try:
        session = await handle_authorization(auth_header, store, resolver)
        print(f"Authenticated session: {session}")
    except ValueError as e:
        print(f"Authentication failed: {e}")

Authentication Flow

  1. Challenge Creation

    • Server creates a challenge with a unique ID and secret
    • Challenge is stored in the session store
    • Challenge is sent to the client
  2. Client Authentication

    • Client resolves the server's DID
    • Client creates a JWT with:
      • Challenge ID and secret
      • Client's DID and verification method
      • EdDSA signature using the client's private key
  3. Server Verification

    • Server validates the JWT signature
    • Server verifies the challenge
    • Server resolves the client's DID
    • Server verifies the client's verification method

API Reference

DID Resolution

class HttpDidResolver:
    def __init__(self, store: Optional[AgenticProfileStore] = None):
        """Create a new HTTP DID resolver with optional caching."""
        pass

    async def resolve(self, did: str) -> Tuple[Dict[str, Any], Dict[str, Any]]:
        """Resolve a DID to its profile document."""
        pass

Authentication

async def create_challenge(store: ClientAgentSessionStore) -> AgenticChallenge:
    """Create a new authentication challenge."""
    pass

async def handle_authorization(
    auth_header: str,
    store: ClientAgentSessionStore,
    resolver: DidResolver
) -> ClientAgentSession:
    """Handle an authorization header and return the authenticated session."""
    pass

Models

  • AgenticProfile: Represents a DID profile document
  • AgentService: Represents an agent service in a profile
  • VerificationMethod: Represents a verification method in a profile
  • ClientAgentSession: Represents an authenticated session
  • AgenticChallenge: Represents an authentication challenge
  • AgenticJwsHeader: JWT header for agentic authentication
  • AgenticJwsPayload: JWT payload for agentic authentication

Development

Setup

# Clone the repository
git clone https://github.com/yourusername/agentic-profile-auth.git
cd agentic-profile-auth

# Create a virtual environment
python -m venv venv
source venv/bin/activate  # or `venv\Scripts\activate` on Windows

# Install development dependencies
pip install -e ".[test]"

Running Tests

pytest

Code Style

The project uses:

  • Black for code formatting
  • MyPy for type checking
  • Ruff for linting

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

agentic_profile_auth-0.1.2.tar.gz (19.6 kB view details)

Uploaded Source

Built Distribution

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

agentic_profile_auth-0.1.2-py3-none-any.whl (16.7 kB view details)

Uploaded Python 3

File details

Details for the file agentic_profile_auth-0.1.2.tar.gz.

File metadata

  • Download URL: agentic_profile_auth-0.1.2.tar.gz
  • Upload date:
  • Size: 19.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.4

File hashes

Hashes for agentic_profile_auth-0.1.2.tar.gz
Algorithm Hash digest
SHA256 80c8073de134a25017f56fe7c00b89ffd96682202103965552d3356f637951a8
MD5 07b25de734ab6717091a7118e66e4f7a
BLAKE2b-256 3abab0a6ec3649e3c1458e8181ce049136b54591ee23356ec3322781416efae6

See more details on using hashes here.

File details

Details for the file agentic_profile_auth-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for agentic_profile_auth-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 41c1e4fae57438b2dc573a979106f0aac7e7a3317aa184d7b98265540b467347
MD5 ddffb7640ccebc8acd50e3cb855e559c
BLAKE2b-256 7a3ff6fdba6235f5085c41a1f92fae2c918940395e3f9c29e28ab5c2c117bdd6

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