Skip to main content

AZTP (Agentic Zero Trust Protocol) Client Library for Python

Project description

AZTP Client Python

AZTP (Agentic Zero Trust Protocol) Client is an enterprise-grade identity service client that provides secure workload identity management using AZTP standards. The client library facilitates secure communication between workloads by managing digital identities and certificates.

Installation

pip install aztp-client

Requirements

  • Python 3.8 or higher

Trusted Domains

The AZTP client maintains a whitelist of trusted domains for use with the trustDomain parameter. When you specify a domain that isn't in this whitelist, the client will display a warning and suggest valid alternatives from the approved list. If no trust domain is specified, the system defaults to aztp.network.

from aztp_client import Aztp, whiteListTrustDomains

# Check available trusted domains
print("Available trusted domains:", whiteListTrustDomains)

# Create a secure connection with a trusted domain
agent = await client.secure_connect(
    crew_agent={},
    "my-agent"
    config={
        "trustDomain": whiteListTrustDomains["gptapps.ai"],  # Using a whitelisted domain
        "isGlobalIdentity": False
    }
)

Current Trusted Domains

  • gptarticles.xyz
  • gptapps.ai
  • vcagents.ai

Quick Start

from aztp_client import Aztp, whiteListTrustDomains

# Initialize client
client = Aztp(api_key="your-api-key")

# Create a secure agent
agent = await client.secure_connect(
    crew_agent={},
    "service1", 
    config={
        "isGlobalIdentity": False
    }
)

# Create a secure agent with a trusted domain
agent_with_domain = await client.secure_connect(
    crew_agent={},
    'service2',
    config={
        "trustDomain": whiteListTrustDomains["gptapps.ai"],,  # Using first whitelisted domain
        "isGlobalIdentity": False
    }
)

# Verify identity
is_valid = await client.verify_identity(agent)


# Verify the identity connection 
is_valid_connection = await client.verify_identity_connection(from_aztp_id, to_aztp_id)

# Check available trusted domains
print("Available trusted domains:", whiteListTrustDomains)

# Get identity details
identity = await client.get_identity(agent)

# Discover identities
discovered_identities = await client.discover_identity()

# Discover identities with trust domain and requestor identity
discovered_identities = await client.discover_identity(trust_domain, requestor_identity)

Example

import asyncio
import os
from aztp_client import Aztp
from dotenv import load_dotenv

# Load the .env file from the correct location
load_dotenv()

async def main():
    # Initialize the client with your API key
    client = Aztp(
        api_key= os.getenv("AZTP_API_KEY")
    )
    name = os.getenv("AZTP_AGENT_NAME")
    otherNameA = os.getenv("AZTP_OTHER_AGENT_NAME_A")
    otherNameB = os.getenv("AZTP_OTHER_AGENT_NAME_B")
    
    # Get trust domain from environment or use a whitelisted domain
    from aztp_client import whiteListTrustDomains
    trustDomain = os.getenv("AZTP_TRUST_DOMAIN") or whiteListTrustDomains["gptapps.ai"]
    
    # Validate trust domain against whitelist
    if trustDomain not in whiteListTrustDomains:
        print(f"Warning: Trust domain '{trustDomain}' is not in the whitelist.")
        print(f"Available trusted domains: {', '.join(whiteListTrustDomains)}")
        trustDomain = 'aztp.network'

    try:
        crewAgent = {}
        crewAgentA = {}
        crewAgentB = {}
        
        # Create a secure agent
        print("\nCreating secure agent...")
        agent = await client.secure_connect(
            crewAgent, 
            name,
            {
                "isGlobalIdentity": True
            }
        )
        print(f"Agent {name} created successfully!")
        
        if agent.identity.aztp_id:
            print(f"Agent: {agent.identity.aztp_id}")

        #Example 1: Create a agent with linked identity
        print("\nCreating agent with linked identity...")
        agentA = await client.secure_connect(
            crewAgentA, 
            otherNameA,
            {
                "linkTo": [agent.identity.aztp_id],
                "isGlobalIdentity": False
            }
        )
        print(f"Agent {otherNameA} created successfully!")
        if agentA.identity.aztp_id:
            print(f"Agent: {agentA.identity.aztp_id}")
        
        #Example 2: Create a agent with linked identity and trust domain
        print("\nCreating agent with linked identity and trust domain...")
        agentB = await client.secure_connect(
            crewAgentB, 
            otherNameB,
            {
                "linkTo": [agent.identity.aztp_id],
                "trustDomain": trustDomain,  # Using validated trust domain from whitelist
                "isGlobalIdentity": False
            }
        )
        print(f"Agent {otherNameB} created successfully!")
        if agentB.identity.aztp_id:
            print(f"Agent: {agentB.identity.aztp_id}")

        
        # Verify the identity
        print(f"\nVerifying agent {name} identity...")
        is_valid = await client.verify_identity(agent)
        print(f"Identity valid: {is_valid}")

        # Verify the identity connection
        print(f"\nVerifying agent {name} identity connection with {otherNameB}...")
        is_valid_connection = await client.verify_identity_connection(agent.identity.aztp_id, agentB.identity.aztp_id)
        print(f"Connection valid: {is_valid_connection}")
        
        # Get identity details
        print(f"\nGetting agent {name} identity details...")
        identity = await client.get_identity(agent)
        if identity:
            print(f"Retrieved identity: {identity}")
        else:
            print("No identity found") 

        # Discover identities
        print(f"\nDiscovering all identities...")
        discovered_identities = await client.discover_identity()
        print(f"Discovered identities: {discovered_identities}")

        # Discover identities with trust domain and requestor identity
        print(f"\nDiscovering identities with trust domain {trustDomain} and requestor identity {agent.identity.aztp_id}...")
        discovered_identities = await client.discover_identity(trust_domain=trustDomain, requestor_identity=agent.identity.aztp_id)
        print(f"Discovered identities with trust domain and requestor identity: {discovered_identities}")

    except ConnectionError as e:
        print(f"Connection Error: Could not connect to the AZTP server. Please check your connection and server URL.")
        print(f"Details: {e}")
    except Exception as e:
        print(f"Error: {str(e)}")
        print("\nCurrent configuration:")
        print(f"Base URL: {client.config.base_url}")
        print(f"Environment: {client.config.environment}")
        print("API Key: ********")  # Don't print the API key for security

if __name__ == "__main__":
    asyncio.run(main())

Features

  • Workload Identity Management using AZTP standards
  • Certificate Management (X.509)
  • Secure Communication
  • Identity Verification
  • Metadata Management
  • Environment-specific Configuration
  • Trusted Domain Validation and Suggestions

License

MIT License

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

aztp_client-1.0.21.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

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

aztp_client-1.0.21-py3-none-any.whl (9.8 kB view details)

Uploaded Python 3

File details

Details for the file aztp_client-1.0.21.tar.gz.

File metadata

  • Download URL: aztp_client-1.0.21.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for aztp_client-1.0.21.tar.gz
Algorithm Hash digest
SHA256 d46f4f87af8fd57f7cef8f4320c3f97fd81c56bef41429457ed9e7a0e50d380f
MD5 37bc8e3257e3740945c7d90f27f17e08
BLAKE2b-256 cccfd9ca8d56f003d07fc646e7877af8ae8a4f492cae6aa5d942f9b7debce88d

See more details on using hashes here.

File details

Details for the file aztp_client-1.0.21-py3-none-any.whl.

File metadata

  • Download URL: aztp_client-1.0.21-py3-none-any.whl
  • Upload date:
  • Size: 9.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for aztp_client-1.0.21-py3-none-any.whl
Algorithm Hash digest
SHA256 8fb2f0445f6f76690b1e1a21f267c60b6b5ba0ab08a60eda695ff1a054b6fd08
MD5 38042e53b6d42c82093709d225cd0e4f
BLAKE2b-256 4fea427643c027677a1e0163f4a21d81f0c7c15b120b0ddd035f94e4e32ff124

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