mirror of
https://github.com/hanzoai/python-sdk.git
synced 2026-10-23 20:23:00 +00:00
refactor(iam): drop Casdoor branding — Hanzo IAM only (white-label) (#41)
Co-authored-by: Hanzo Dev <[email protected]>
This commit is contained in:
committed by
GitHub
co-authored by
Hanzo Dev
parent
4c61d0a9c2
commit
bd0307b62b
@@ -1,6 +1,6 @@
|
||||
# hanzoai-iam
|
||||
|
||||
Identity and Access Management SDK for the Hanzo ecosystem. Built on Casdoor with organization-aware multi-tenancy.
|
||||
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`.
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"""Hanzo IAM - Identity and Access Management SDK for Hanzo ecosystem."""
|
||||
|
||||
from hanzo_iam.async_client import AsyncCasdoorSDK, AsyncIAMClient
|
||||
from hanzo_iam.client import CasdoorSDK, IAMClient
|
||||
from hanzo_iam.async_client import AsyncIAMClient
|
||||
from hanzo_iam.client import IAMClient
|
||||
from hanzo_iam.models import (
|
||||
Application,
|
||||
IAMConfig,
|
||||
@@ -27,7 +27,4 @@ __all__ = [
|
||||
"TokenResponse",
|
||||
"User",
|
||||
"UserInfo",
|
||||
# Aliases for Casdoor compatibility
|
||||
"CasdoorSDK",
|
||||
"AsyncCasdoorSDK",
|
||||
]
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
"""Asynchronous IAM client for Hanzo IAM (Casdoor-based)."""
|
||||
"""Asynchronous IAM client for Hanzo IAM."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
@@ -423,7 +423,7 @@ class AsyncIAMClient:
|
||||
return UserInfo.model_validate(response.json())
|
||||
|
||||
# =========================================================================
|
||||
# User Management (Casdoor Admin API)
|
||||
# User Management (IAM Admin API)
|
||||
# =========================================================================
|
||||
|
||||
async def get_user(self, user_id: str) -> User:
|
||||
@@ -1041,7 +1041,3 @@ class AsyncIAMClient:
|
||||
|
||||
async def __aexit__(self, *args: Any) -> None:
|
||||
await self.close()
|
||||
|
||||
|
||||
# Alias for Casdoor SDK compatibility
|
||||
AsyncCasdoorSDK = AsyncIAMClient
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
"""
|
||||
Hanzo IAM Client - Sync OAuth2/OIDC client for Hanzo Identity.
|
||||
|
||||
Compatible with Casdoor API. Supports multiple organizations.
|
||||
Supports multiple organizations.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
@@ -450,7 +450,7 @@ class IAMClient:
|
||||
return {}
|
||||
|
||||
# =========================================================================
|
||||
# User Management (Casdoor Admin API)
|
||||
# User Management (IAM Admin API)
|
||||
# =========================================================================
|
||||
|
||||
def get_user(self, user_id: str) -> User:
|
||||
@@ -567,7 +567,7 @@ class IAMClient:
|
||||
return self._modify_user("delete-user", user)
|
||||
|
||||
def _modify_user(self, action: str, user: User) -> dict:
|
||||
"""Modify user via Casdoor admin API."""
|
||||
"""Modify user via IAM admin API."""
|
||||
response = self.http.post(
|
||||
f"/api/{action}",
|
||||
params=self._admin_params(),
|
||||
@@ -1130,8 +1130,3 @@ class AsyncIAMClient:
|
||||
|
||||
async def __aexit__(self, *args) -> None:
|
||||
await self.close()
|
||||
|
||||
|
||||
# Aliases for Casdoor SDK compatibility
|
||||
CasdoorSDK = IAMClient
|
||||
AsyncCasdoorSDK = AsyncIAMClient
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
"""Pydantic models for Hanzo IAM (Casdoor-based)."""
|
||||
"""Pydantic models for Hanzo IAM."""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
@@ -8,8 +8,8 @@ from typing import Any
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, Field
|
||||
|
||||
# Canonical OIDC UserInfo path (HIP-0111). One way; no legacy /api/ prefix,
|
||||
# no Casdoor /api/get-account. Relative to the IAM server_url root.
|
||||
# Canonical OIDC UserInfo path (HIP-0111). One way; no legacy /api/ prefix.
|
||||
# Relative to the IAM server_url root.
|
||||
OIDC_USERINFO_PATH = "/v1/iam/oauth/userinfo"
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"""Hanzo IAM - Identity and Access Management CLI.
|
||||
|
||||
Real API calls to Casdoor-based IAM at hanzo.id.
|
||||
Real API calls to Hanzo IAM at hanzo.id.
|
||||
Manages users, organizations, providers, roles, and applications.
|
||||
"""
|
||||
|
||||
@@ -202,7 +202,7 @@ def configure(url: str, client_id: str, client_secret: str, org: str):
|
||||
os.environ["IAM_CLIENT_SECRET"] = client_secret
|
||||
os.environ["IAM_URL"] = url
|
||||
# HIP-0111: canonical OIDC userinfo. Returns flat standard claims
|
||||
# (sub/email/...) with no Casdoor {status,msg} envelope — a 200
|
||||
# (sub/email/...) with no {status,msg} envelope — a 200
|
||||
# response is itself the success signal; any failure raises via
|
||||
# raise_for_status in _iam_request.
|
||||
data = _iam_request("GET", "/v1/iam/oauth/userinfo", auth_params=True)
|
||||
@@ -1125,7 +1125,7 @@ def iam_login(username: str, password: str, org: str, app: str):
|
||||
"""Login as a user via IAM (email/password).
|
||||
|
||||
\b
|
||||
Uses the Casdoor /api/login endpoint directly.
|
||||
Uses the IAM /api/login endpoint directly.
|
||||
Stores the resulting token in ~/.hanzo/auth.json.
|
||||
|
||||
\b
|
||||
|
||||
@@ -1512,7 +1512,7 @@ def install_runtime(setup: bool, sdk: str, computer_use: bool):
|
||||
|
||||
|
||||
# ============================================================================
|
||||
# Cas Infrastructure (Casdoor, Casibase, Casvisor)
|
||||
# Cas Infrastructure (Hanzo IAM / Hanzo Cloud)
|
||||
# ============================================================================
|
||||
|
||||
CAS_PATH = Path.home() / "work" / "cas"
|
||||
@@ -1527,15 +1527,15 @@ def install_cas(component: str, setup: bool, start: bool):
|
||||
|
||||
\b
|
||||
Components:
|
||||
casdoor - Authentication/IAM system (Single Sign-On)
|
||||
hanzo-iam - Authentication/IAM system (Single Sign-On)
|
||||
casibase - AI Cloud OS with MCP/A2A support
|
||||
casvisor - Cloud operating system (VM/machine management)
|
||||
|
||||
\b
|
||||
Examples:
|
||||
hanzo install cas # Check status
|
||||
hanzo install cas casdoor --setup # Set up Casdoor
|
||||
hanzo install cas casibase --start # Start Casibase
|
||||
hanzo install cas # Check status
|
||||
hanzo install cas hanzo-iam --setup # Set up Hanzo IAM
|
||||
hanzo install cas casibase --start # Start Casibase
|
||||
|
||||
\b
|
||||
Casibase Features:
|
||||
@@ -1547,18 +1547,20 @@ def install_cas(component: str, setup: bool, start: bool):
|
||||
cas_dir = CAS_PATH
|
||||
|
||||
components_info = {
|
||||
"casdoor": {
|
||||
"name": "Casdoor",
|
||||
"hanzo-iam": {
|
||||
"name": "Hanzo IAM",
|
||||
"description": "Authentication/IAM - Single Sign-On",
|
||||
"path": cas_dir / "casdoor",
|
||||
"path": cas_dir / "hanzo-iam",
|
||||
"port": 8000,
|
||||
"docs": "https://casdoor.org",
|
||||
"repo": "https://github.com/hanzoai/iam",
|
||||
"docs": "https://docs.hanzo.ai/iam",
|
||||
},
|
||||
"casibase": {
|
||||
"name": "Casibase",
|
||||
"description": "AI Cloud OS - Knowledge base + MCP/A2A",
|
||||
"path": cas_dir / "casibase",
|
||||
"port": 14000,
|
||||
"repo": "https://github.com/casibase/casibase",
|
||||
"docs": "https://casibase.org",
|
||||
},
|
||||
"casvisor": {
|
||||
@@ -1566,6 +1568,7 @@ def install_cas(component: str, setup: bool, start: bool):
|
||||
"description": "Cloud OS - VM/Machine management",
|
||||
"path": cas_dir / "casvisor",
|
||||
"port": 16001,
|
||||
"repo": "https://github.com/casvisor/casvisor",
|
||||
"docs": "https://casvisor.org",
|
||||
},
|
||||
}
|
||||
@@ -1581,9 +1584,7 @@ def install_cas(component: str, setup: bool, start: bool):
|
||||
|
||||
if not comp_path.exists():
|
||||
console.print(f"[red]{info['name']} not found at: {comp_path}[/red]")
|
||||
console.print(
|
||||
f"Clone: git clone https://github.com/{component}/{component} {comp_path}"
|
||||
)
|
||||
console.print(f"Clone: git clone {info['repo']} {comp_path}")
|
||||
return
|
||||
|
||||
if setup:
|
||||
@@ -1637,7 +1638,7 @@ def install_cas(component: str, setup: bool, start: bool):
|
||||
|
||||
else:
|
||||
# Status check
|
||||
console.print("[bold]Cas Infrastructure[/bold]")
|
||||
console.print("[bold]Cas Infrastructure (Hanzo IAM / Hanzo Cloud)[/bold]")
|
||||
console.print()
|
||||
|
||||
for comp_id, info in components_info.items():
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
Supports multiple authentication methods:
|
||||
1. API Key (HANZO_API_KEY, ANTHROPIC_API_KEY, OPENAI_API_KEY)
|
||||
2. Email/Password via IAM (iam.hanzo.ai - Casdoor)
|
||||
2. Email/Password via Hanzo IAM (iam.hanzo.ai)
|
||||
3. SSO authentication
|
||||
4. Anthropic OAuth (PKCE via console.anthropic.com)
|
||||
5. OpenAI/ChatGPT OAuth (device code via auth.openai.com)
|
||||
|
||||
@@ -81,7 +81,7 @@ class SimpleLLMClient:
|
||||
os.environ["OPENAI_API_KEY"] = self.api_key # For OpenAI compatibility
|
||||
|
||||
def _iam_login(self):
|
||||
"""Login using IAM (Casdoor) authentication."""
|
||||
"""Login using Hanzo IAM authentication."""
|
||||
try:
|
||||
import webbrowser
|
||||
from urllib.parse import urlencode
|
||||
|
||||
@@ -23,10 +23,10 @@ __all__ = ["IAMResource", "AsyncIAMResource"]
|
||||
class IAMResource(SyncAPIResource):
|
||||
"""Hanzo IAM — identity, access, and organization management.
|
||||
|
||||
Wraps the Casdoor-compatible API at hanzo.id/api/ behind the /iam/ gateway
|
||||
Wraps the IAM API at hanzo.id/api/ behind the /iam/ gateway
|
||||
prefix. Auth endpoints accept explicit params; CRUD endpoints for users,
|
||||
organizations, applications, roles, permissions, groups, tokens, sessions,
|
||||
and invitations accept full object dicts matching the Casdoor schema.
|
||||
and invitations accept full object dicts matching the IAM schema.
|
||||
"""
|
||||
|
||||
@cached_property
|
||||
|
||||
@@ -13,7 +13,7 @@ from .._base_client import make_request_options
|
||||
|
||||
|
||||
class IdentityResource(SyncAPIResource):
|
||||
"""Identity and authentication management (Casdoor-backed)."""
|
||||
"""Identity and authentication management (Hanzo IAM-backed)."""
|
||||
|
||||
@cached_property
|
||||
def with_raw_response(self) -> IdentityResourceWithRawResponse:
|
||||
@@ -443,7 +443,7 @@ class IdentityResource(SyncAPIResource):
|
||||
|
||||
|
||||
class AsyncIdentityResource(AsyncAPIResource):
|
||||
"""Identity and authentication management (Casdoor-backed)."""
|
||||
"""Identity and authentication management (Hanzo IAM-backed)."""
|
||||
|
||||
@cached_property
|
||||
def with_raw_response(self) -> AsyncIdentityResourceWithRawResponse:
|
||||
|
||||
Reference in New Issue
Block a user