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
-
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
-
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
-
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 documentAgentService: Represents an agent service in a profileVerificationMethod: Represents a verification method in a profileClientAgentSession: Represents an authenticated sessionAgenticChallenge: Represents an authentication challengeAgenticJwsHeader: JWT header for agentic authenticationAgenticJwsPayload: 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
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 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
80c8073de134a25017f56fe7c00b89ffd96682202103965552d3356f637951a8
|
|
| MD5 |
07b25de734ab6717091a7118e66e4f7a
|
|
| BLAKE2b-256 |
3abab0a6ec3649e3c1458e8181ce049136b54591ee23356ec3322781416efae6
|
File details
Details for the file agentic_profile_auth-0.1.2-py3-none-any.whl.
File metadata
- Download URL: agentic_profile_auth-0.1.2-py3-none-any.whl
- Upload date:
- Size: 16.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
41c1e4fae57438b2dc573a979106f0aac7e7a3317aa184d7b98265540b467347
|
|
| MD5 |
ddffb7640ccebc8acd50e3cb855e559c
|
|
| BLAKE2b-256 |
7a3ff6fdba6235f5085c41a1f92fae2c918940395e3f9c29e28ab5c2c117bdd6
|