Skip to main content

hanzoai-iam

Identity and Access Management SDK for the Hanzo ecosystem. Organization-aware multi-tenant IAM for the Hanzo ecosystem.

The PyPI distribution is hanzoai-iam; the import path is hanzo_iam.

Installation

pip install hanzoai-iam

With FastAPI integration:

pip install hanzoai-iam[fastapi]

With KMS support for certificate management:

pip install hanzoai-iam[kms]

Quick Start

from hanzo_iam import IAMClient, IAMConfig

config = IAMConfig(
    endpoint="https://iam.hanzo.ai",
    client_id="your-client-id",
    client_secret="your-client-secret",
    org_name="HANZO",
)

client = IAMClient(config)

# Get authorization URL for user login
auth_url = client.get_auth_url(redirect_uri="https://yourapp.com/callback")

# Exchange code for tokens
tokens = client.get_token(code="auth-code-from-callback")

# Get user info
user = client.get_user_info(access_token=tokens.access_token)

Organizations

Organization Endpoint Description
HANZO https://iam.hanzo.ai Hanzo AI platform
ZOO https://iam.zoo.dev Zoo Labs Foundation
LUX https://iam.lux.network Lux blockchain network
PARS https://iam.pars.dev Pars development platform

Environment Variables

One canonical prefix — IAM_*. No upstream-brand aliases, no per-org variants.

# Required
IAM_ENDPOINT=https://hanzo.id
IAM_CLIENT_ID=your-client-id
IAM_CLIENT_SECRET=your-client-secret

# Optional (defaults shown)
IAM_ORG=hanzo
IAM_APP=app
IAM_CERT=path/to/cert.pem    # PEM file or inline PEM content

FastAPI Integration

from fastapi import FastAPI, Depends
from hanzo_iam.fastapi import IAMAuth, get_current_user
from hanzo_iam import IAMConfig, User

app = FastAPI()

config = IAMConfig.from_env()
auth = IAMAuth(config)

@app.get("/protected")
async def protected_route(user: User = Depends(auth.require_user)):
    return {"user": user.name, "org": user.owner}

@app.get("/optional")
async def optional_auth(user: User | None = Depends(auth.optional_user)):
    if user:
        return {"message": f"Hello, {user.name}"}
    return {"message": "Hello, anonymous"}

Client Credentials Flow

For service-to-service authentication:

from hanzo_iam import IAMClient, IAMConfig

config = IAMConfig(
    endpoint="https://iam.hanzo.ai",
    client_id="service-client-id",
    client_secret="service-client-secret",
    org_name="HANZO",
)

client = IAMClient(config)

# Get service token
tokens = client.get_client_credentials_token()

# Use token for API calls
headers = {"Authorization": f"Bearer {tokens.access_token}"}

Async Client

import asyncio
from hanzo_iam import AsyncIAMClient, IAMConfig

async def main():
    config = IAMConfig.from_env()
    client = AsyncIAMClient(config)

    # All methods are async
    tokens = await client.get_client_credentials_token()
    user = await client.get_user_info(tokens.access_token)

    print(f"Authenticated as: {user.name}")

asyncio.run(main())

API Reference

Method Description
get_auth_url(redirect_uri, state, scope) Generate OAuth authorization URL
get_token(code) Exchange authorization code for tokens
refresh_token(refresh_token) Refresh access token
get_client_credentials_token() Get token via client credentials flow
get_user_info(access_token) Get user info from access token
parse_jwt(token) Parse and validate JWT claims
get_user(user_id) Get user by ID
get_users() List all users in organization
create_user(user) Create new user
update_user(user) Update existing user
delete_user(user_id) Delete user
get_organizations() List organizations
get_organization(name) Get organization by name

License

Apache-2.0

Metadata

Release files for hanzo-iam 1.30.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hanzo-iam 1.30.2
File Size Uploaded Provenance Actions
hanzo_iam-1.30.2.tar.gz 67.0 kB Without provenance Details for hanzo_iam-1.30.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for hanzo-iam 1.30.2
File Interpreter ABI Platform Actions
hanzo_iam-1.30.2-py3-none-any.whl Python 3 none any Details for hanzo_iam-1.30.2-py3-none-any.whl

Total release size: 100.2 kB

Release files / hanzo_iam-1.30.2.tar.gz

Download URL hanzo_iam-1.30.2.tar.gz
Size 67.0 kB
Tags Source
SHA-256 checksum
How to use checksums
e4556f048e9950f3ab75114bfeb22f9c7d69f4322a8c78096d2fccf80e75d027
BLAKE2b-256 checksum
How to use checksums
3623a1f0742d23072d66af70249c9f33367f07590e92a37fdccba181143a1758
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / hanzo_iam-1.30.2-py3-none-any.whl

Download URL hanzo_iam-1.30.2-py3-none-any.whl
Size 33.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f9781e320698e4005cac67a205f79a5eb74f646e144d90b8198d0858258f352c
BLAKE2b-256 checksum
How to use checksums
45b2baf1ade94ddc34d98a633981bed10626637120e7b89a6c088775fe9741eb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Security for hanzo-iam 1.30.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page