miso-client


Namemiso-client JSON
Version 0.1.0 PyPI version JSON
download
home_pagehttps://github.com/aifabrix/miso-client-python
SummaryPython client SDK for AI Fabrix authentication, authorization, and logging
upload_time2025-10-30 14:39:26
maintainerNone
docs_urlNone
authorAI Fabrix Team
requires_python>=3.8
licenseNone
keywords authentication authorization rbac jwt redis logging aifabrix miso
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # AI Fabrix Miso Client SDK (Python)

[![PyPI version](https://badge.fury.io/py/miso-client.svg)](https://badge.fury.io/py/miso-client)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

The **AI Fabrix Miso Client SDK** provides authentication, authorization, and logging for Python applications integrated with the AI Fabrix platform.

## ✨ Benefits

### 🔐 Enterprise Security

**SSO and Federated Identity**
- Single Sign-On (SSO) with Keycloak
- OAuth 2.0 and OpenID Connect (OIDC) support
- Multi-factor authentication (MFA) ready
- Social login integration (Google, Microsoft, etc.)

**Centralized Access Control**
- Role-based access control (RBAC)
- Fine-grained permissions
- Dynamic policy enforcement
- Attribute-based access control (ABAC)

**API Security**
- JWT token validation
- API key authentication
- Token revocation support
- Secure token storage
- Data encryption/decryption (AES-256-GCM)

### 📊 Compliance & Audit

**ISO 27001 Compliance**
- Comprehensive audit trails for all user actions
- Data access logging and monitoring
- Security event tracking
- Accountability and non-repudiation

**Regulatory Compliance**
- GDPR-ready data protection
- HIPAA-compliant audit logging
- SOC 2 audit trail requirements
- Industry-standard security controls

**Audit Capabilities**
- Real-time audit event logging
- Immutable audit records
- Forensic analysis support
- Compliance reporting automation

### ⚡ Performance & Scalability

**Intelligent Caching**
- Redis-based role and permission caching
- Generic cache service with Redis and in-memory fallback
- Configurable cache TTL (default: 15 minutes)
- Automatic cache invalidation
- Fallback to controller when Redis unavailable

**High Availability**
- Automatic failover to controller
- Redundant infrastructure support
- Load balancing compatible
- Zero-downtime deployments

**Optimized Network**
- Efficient API calls with caching
- Batch operations support
- Connection pooling
- Minimal latency

### 🛠️ Developer Experience

**Easy Integration**
- Progressive activation (6-step setup)
- Works with any framework (FastAPI, Django, Flask, Starlette)
- Python 3.8+ support with full type hints
- Async/await support throughout

**Flexible Configuration**
- Environment-based configuration
- Support for dev, test, and production environments
- Docker and Kubernetes ready
- CI/CD friendly

**Observability**
- Centralized logging with correlation IDs
- Performance tracking and metrics
- Error tracking and debugging
- Health monitoring

---

## 🚀 Quick Start

Get your application secured in 30 seconds.

### Step 1: Install

```bash
pip install miso-client
```

### Step 2: Create `.env`

```bash
MISO_CLIENTID=ctrl-dev-my-app
MISO_CLIENTSECRET=your-secret
MISO_CONTROLLER_URL=http://localhost:3000
REDIS_HOST=localhost
```

### Step 3: Use It

```python
from miso_client import MisoClient, load_config

client = MisoClient(load_config())
await client.initialize()

is_valid = await client.validate_token(token)
```

**That's it!** You now have authentication, roles, and logging.

→ [Full Getting Started Guide](docs/getting-started.md)

---

### Infrastructure Setup

**First time?** You'll need Keycloak and Miso Controller running.

Use the [AI Fabrix Builder](https://github.com/esystemsdev/aifabrix-builder/blob/main/docs/QUICK-START.md):

```bash
# Start infrastructure (Postgres, Redis)
aifabrix up

# Install Keycloak for authentication
aifabrix create keycloak --port 8082 --database --template platform
aifabrix build keycloak
aifabrix run keycloak

# Install Miso Controller
aifabrix create miso-controller --port 3000 --database --redis --template platform
aifabrix build miso-controller
aifabrix run miso-controller
```

→ [Infrastructure Guide](https://github.com/esystemsdev/aifabrix-builder/blob/main/docs/INFRASTRUCTURE.md)

**Already have Keycloak and Controller?** Use the Quick Start above.

---

## 📚 Documentation

**What happens:** Your app validates user tokens from Keycloak.

```python
from miso_client import MisoClient, load_config

# Create client (loads from .env automatically)
client = MisoClient(load_config())
await client.initialize()

# Get token from request (helper method)
token = client.get_token(req)

if token:
    is_valid = await client.validate_token(token)
    if is_valid:
        user = await client.get_user(token)
        print('User:', user)
```

**Where to get tokens?** Users authenticate via Keycloak, then your app receives JWTs in the `Authorization` header.

→ [Complete authentication example](examples/step-3-authentication.py)

---

### Step 4: Activate RBAC (Roles)

**What happens:** Check user roles to control access. Roles are cached in Redis for performance.

```python
from miso_client import MisoClient, load_config

# Build on Step 3 - add Redis in .env file
client = MisoClient(load_config())
await client.initialize()

token = client.get_token(req)

# Check if user has role
is_admin = await client.has_role(token, 'admin')
roles = await client.get_roles(token)

# Gate features by role
if is_admin:
    # Show admin panel
    pass
```

**Pro tip:** Without Redis, checks go to the controller. Add Redis to cache role lookups (15-minute default TTL).

→ [Complete RBAC example](examples/step-4-rbac.py)  
→ [AI Fabrix Builder Quick Start](https://github.com/esystemsdev/aifabrix-builder/blob/main/docs/QUICK-START.md)

---

### Step 5: Activate Logging

**What happens:** Application logs are sent to the Miso Controller with client token authentication.

```python
from miso_client import MisoClient, load_config

# Client token is automatically managed - no API key needed
client = MisoClient(load_config())
await client.initialize()

token = client.get_token(req)
user = await client.get_user(token)

# Log messages
await client.log.info('User accessed dashboard', {'userId': user.id if user else None})
await client.log.error('Operation failed', {'error': str(err)})
await client.log.warn('Unusual activity', {'details': '...'})
```

**What happens to logs?** They're sent to the Miso Controller for centralized monitoring and analysis. Client token is automatically included.

→ [Complete logging example](examples/step-5-logging.py)  
→ [Logging Reference](docs/api-reference.md#logger-service)

---

### Step 6: Activate Audit

**What happens:** Create audit trails for compliance and security monitoring.

```python
from miso_client import MisoClient, load_config

# Complete configuration (all in .env)
client = MisoClient(load_config())
await client.initialize()

token = client.get_token(req)
is_valid = await client.validate_token(token)
can_edit = await client.has_permission(token, 'edit:content')
user = await client.get_user(token)

# Audit: User actions
await client.log.audit('user.login', 'authentication', {
    'userId': user.id if user else None,
    'ip': req.get('ip', ''),
    'userAgent': req.get('headers', {}).get('user-agent', ''),
})

# Audit: Content changes
await client.log.audit('post.created', 'content', {
    'userId': user.id if user else None,
    'postId': 'post-123',
    'postTitle': req.get('body', {}).get('title', ''),
})

# Audit: Permission checks
await client.log.audit('access.denied', 'authorization', {
    'userId': user.id if user else None,
    'requiredPermission': 'edit:content',
    'resource': 'posts',
})
```

**What to audit:** Login/logout, permission checks, content creation/deletion, role changes, sensitive operations.

→ [Complete audit example](examples/step-6-audit.py)  
→ [Best Practices](docs/getting-started.md#common-patterns)

---

### Encryption and Caching

**What happens:** Use encryption for sensitive data and generic caching for improved performance.

```python
from miso_client import MisoClient, load_config

client = MisoClient(load_config())
await client.initialize()

# Encryption (requires ENCRYPTION_KEY in .env)
encrypted = client.encrypt('sensitive-data')
decrypted = client.decrypt(encrypted)
print('Decrypted:', decrypted)

# Generic caching (automatically uses Redis if available, falls back to memory)
await client.cache_set('user:123', {'name': 'John', 'age': 30}, 600)  # 10 minutes TTL
user = await client.cache_get('user:123')
if user:
    print('Cached user:', user)
```

**Configuration:**

```bash
# Add to .env
ENCRYPTION_KEY=your-32-byte-encryption-key
```

→ [API Reference](docs/api-reference.md#encryption-methods)  
→ [Cache Methods](docs/api-reference.md#cache-methods)

---

## 🔧 Configuration

```python
from miso_client import MisoClientConfig, RedisConfig

config = MisoClientConfig(
    controller_url="http://localhost:3000",  # Required: Controller URL
    client_id="ctrl-dev-my-app",              # Required: Client ID
    client_secret="your-secret",              # Required: Client secret
    redis=RedisConfig(                        # Optional: For caching
        host="localhost",
        port=6379,
    ),
    log_level="info",                         # Optional: 'debug' | 'info' | 'warn' | 'error'
    cache={                                   # Optional: Cache TTL settings
        "role_ttl": 900,       # Role cache TTL (default: 900s)
        "permission_ttl": 900, # Permission cache TTL (default: 900s)
    }
)
```

**Recommended:** Use `load_config()` to load from `.env` file automatically.

→ [Complete Configuration Reference](docs/configuration.md)

---

## 📚 Documentation

- **[Getting Started](docs/getting-started.md)** - Detailed setup guide
- **[API Reference](docs/api-reference.md)** - Complete API documentation
- **[Configuration](docs/configuration.md)** - Configuration options
- **[Examples](docs/examples.md)** - Framework-specific examples
- **[Troubleshooting](docs/troubleshooting.md)** - Common issues and solutions

---

## 🏗️ Architecture

The SDK consists of five core services:

- **AuthService** - Token validation and user authentication
- **RoleService** - Role management with Redis caching
- **PermissionService** - Fine-grained permissions
- **LoggerService** - Centralized logging with API key authentication
- **RedisService** - Caching and queue management (optional)

→ [Architecture Details](docs/api-reference.md#architecture)

---

## 🌐 Setup Your Application

**First time setup?** Use the AI Fabrix Builder:

1. **Create your app:**
   ```bash
   aifabrix create myapp --port 3000 --database --language python
   ```

2. **Login to controller:**
   ```bash
   aifabrix login
   ```

3. **Register your application:**
   ```bash
   aifabrix app register myapp --environment dev
   ```

4. **Start development** and then deploy to Docker or Azure.

→ [Full Quick Start Guide](https://github.com/esystemsdev/aifabrix-builder/blob/main/docs/QUICK-START.md)

---

## 💡 Next Steps

### Learn More
- [FastAPI Integration](docs/examples.md#fastapi-integration) - Protect API routes
- [Django Middleware](docs/examples.md#django-middleware) - Django integration
- [Flask Decorators](docs/examples.md#flask-decorators) - Decorator-based auth
- [Error Handling](docs/examples.md#error-handling) - Best practices

### Common Tasks

**Add authentication middleware (FastAPI):**
```python
from fastapi import Depends, HTTPException, Security
from fastapi.security import HTTPBearer
from miso_client import MisoClient

security = HTTPBearer()
client = MisoClient(load_config())

async def get_current_user(credentials = Security(security)):
    token = credentials.credentials
    is_valid = await client.validate_token(token)
    if not is_valid:
        raise HTTPException(status_code=401, detail="Invalid token")
    return await client.get_user(token)
```

**Protect routes by role (FastAPI):**
```python
@app.get('/admin')
async def admin_panel(user = Depends(get_current_user), credentials = Security(security)):
    token = credentials.credentials
    is_admin = await client.has_role(token, 'admin')
    if not is_admin:
        raise HTTPException(status_code=403, detail="Forbidden")
    
    # Admin only code
    return {"message": "Admin panel"}
```

**Use environment variables:**
```bash
MISO_CLIENTID=ctrl-dev-my-app
MISO_CLIENTSECRET=your-secret
MISO_CONTROLLER_URL=http://localhost:3000
REDIS_HOST=localhost
REDIS_PORT=6379
MISO_LOG_LEVEL=info
```

---

## 🐛 Troubleshooting

**"Cannot connect to controller"**  
→ Verify `controllerUrl` is correct and accessible  
→ Check network connectivity

**"Redis connection failed"**  
→ SDK falls back to controller-only mode (slower but works)  
→ Fix: `aifabrix up` to start Redis

**"Client token fetch failed"**  
→ Check `MISO_CLIENTID` and `MISO_CLIENTSECRET` are correct  
→ Verify credentials are configured in controller  
→ Ensure `ENCRYPTION_KEY` environment variable is set (required for encryption service)

**"Token validation fails"**  
→ Ensure Keycloak is running and configured correctly  
→ Verify token is from correct Keycloak instance  
→ Check that `python-dotenv` is installed if using `.env` files

→ [More Help](docs/troubleshooting.md)

---

## 📦 Installation

```bash
# pip
pip install miso-client

# Development mode
pip install -e .

# With dev dependencies
pip install "miso-client[dev]"
```

---

## 🔗 Links

- **GitHub Repository**: [https://github.com/esystemsdev/aifabrix-miso-client-python](https://github.com/esystemsdev/aifabrix-miso-client-python)
- **PyPI Package**: [https://pypi.org/project/miso-client/](https://pypi.org/project/miso-client/)
- **Builder Documentation**: [https://github.com/esystemsdev/aifabrix-builder](https://github.com/esystemsdev/aifabrix-builder)
- **Issues**: [https://github.com/esystemsdev/aifabrix-miso-client-python/issues](https://github.com/esystemsdev/aifabrix-miso-client-python/issues)

---

## 📄 License

This project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details.

---

**Made with ❤️ by eSystems Nordic Ltd.**

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/aifabrix/miso-client-python",
    "name": "miso-client",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "AI Fabrix Team <team@aifabrix.ai>",
    "keywords": "authentication, authorization, rbac, jwt, redis, logging, aifabrix, miso",
    "author": "AI Fabrix Team",
    "author_email": "AI Fabrix Team <team@aifabrix.ai>",
    "download_url": "https://files.pythonhosted.org/packages/bb/6d/74792c117e9db85ecdaf227b99c419f89c8b373455db9f7bdf69e6ae209a/miso_client-0.1.0.tar.gz",
    "platform": null,
    "description": "# AI Fabrix Miso Client SDK (Python)\n\n[![PyPI version](https://badge.fury.io/py/miso-client.svg)](https://badge.fury.io/py/miso-client)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\nThe **AI Fabrix Miso Client SDK** provides authentication, authorization, and logging for Python applications integrated with the AI Fabrix platform.\n\n## \u2728 Benefits\n\n### \ud83d\udd10 Enterprise Security\n\n**SSO and Federated Identity**\n- Single Sign-On (SSO) with Keycloak\n- OAuth 2.0 and OpenID Connect (OIDC) support\n- Multi-factor authentication (MFA) ready\n- Social login integration (Google, Microsoft, etc.)\n\n**Centralized Access Control**\n- Role-based access control (RBAC)\n- Fine-grained permissions\n- Dynamic policy enforcement\n- Attribute-based access control (ABAC)\n\n**API Security**\n- JWT token validation\n- API key authentication\n- Token revocation support\n- Secure token storage\n- Data encryption/decryption (AES-256-GCM)\n\n### \ud83d\udcca Compliance & Audit\n\n**ISO 27001 Compliance**\n- Comprehensive audit trails for all user actions\n- Data access logging and monitoring\n- Security event tracking\n- Accountability and non-repudiation\n\n**Regulatory Compliance**\n- GDPR-ready data protection\n- HIPAA-compliant audit logging\n- SOC 2 audit trail requirements\n- Industry-standard security controls\n\n**Audit Capabilities**\n- Real-time audit event logging\n- Immutable audit records\n- Forensic analysis support\n- Compliance reporting automation\n\n### \u26a1 Performance & Scalability\n\n**Intelligent Caching**\n- Redis-based role and permission caching\n- Generic cache service with Redis and in-memory fallback\n- Configurable cache TTL (default: 15 minutes)\n- Automatic cache invalidation\n- Fallback to controller when Redis unavailable\n\n**High Availability**\n- Automatic failover to controller\n- Redundant infrastructure support\n- Load balancing compatible\n- Zero-downtime deployments\n\n**Optimized Network**\n- Efficient API calls with caching\n- Batch operations support\n- Connection pooling\n- Minimal latency\n\n### \ud83d\udee0\ufe0f Developer Experience\n\n**Easy Integration**\n- Progressive activation (6-step setup)\n- Works with any framework (FastAPI, Django, Flask, Starlette)\n- Python 3.8+ support with full type hints\n- Async/await support throughout\n\n**Flexible Configuration**\n- Environment-based configuration\n- Support for dev, test, and production environments\n- Docker and Kubernetes ready\n- CI/CD friendly\n\n**Observability**\n- Centralized logging with correlation IDs\n- Performance tracking and metrics\n- Error tracking and debugging\n- Health monitoring\n\n---\n\n## \ud83d\ude80 Quick Start\n\nGet your application secured in 30 seconds.\n\n### Step 1: Install\n\n```bash\npip install miso-client\n```\n\n### Step 2: Create `.env`\n\n```bash\nMISO_CLIENTID=ctrl-dev-my-app\nMISO_CLIENTSECRET=your-secret\nMISO_CONTROLLER_URL=http://localhost:3000\nREDIS_HOST=localhost\n```\n\n### Step 3: Use It\n\n```python\nfrom miso_client import MisoClient, load_config\n\nclient = MisoClient(load_config())\nawait client.initialize()\n\nis_valid = await client.validate_token(token)\n```\n\n**That's it!** You now have authentication, roles, and logging.\n\n\u2192 [Full Getting Started Guide](docs/getting-started.md)\n\n---\n\n### Infrastructure Setup\n\n**First time?** You'll need Keycloak and Miso Controller running.\n\nUse the [AI Fabrix Builder](https://github.com/esystemsdev/aifabrix-builder/blob/main/docs/QUICK-START.md):\n\n```bash\n# Start infrastructure (Postgres, Redis)\naifabrix up\n\n# Install Keycloak for authentication\naifabrix create keycloak --port 8082 --database --template platform\naifabrix build keycloak\naifabrix run keycloak\n\n# Install Miso Controller\naifabrix create miso-controller --port 3000 --database --redis --template platform\naifabrix build miso-controller\naifabrix run miso-controller\n```\n\n\u2192 [Infrastructure Guide](https://github.com/esystemsdev/aifabrix-builder/blob/main/docs/INFRASTRUCTURE.md)\n\n**Already have Keycloak and Controller?** Use the Quick Start above.\n\n---\n\n## \ud83d\udcda Documentation\n\n**What happens:** Your app validates user tokens from Keycloak.\n\n```python\nfrom miso_client import MisoClient, load_config\n\n# Create client (loads from .env automatically)\nclient = MisoClient(load_config())\nawait client.initialize()\n\n# Get token from request (helper method)\ntoken = client.get_token(req)\n\nif token:\n    is_valid = await client.validate_token(token)\n    if is_valid:\n        user = await client.get_user(token)\n        print('User:', user)\n```\n\n**Where to get tokens?** Users authenticate via Keycloak, then your app receives JWTs in the `Authorization` header.\n\n\u2192 [Complete authentication example](examples/step-3-authentication.py)\n\n---\n\n### Step 4: Activate RBAC (Roles)\n\n**What happens:** Check user roles to control access. Roles are cached in Redis for performance.\n\n```python\nfrom miso_client import MisoClient, load_config\n\n# Build on Step 3 - add Redis in .env file\nclient = MisoClient(load_config())\nawait client.initialize()\n\ntoken = client.get_token(req)\n\n# Check if user has role\nis_admin = await client.has_role(token, 'admin')\nroles = await client.get_roles(token)\n\n# Gate features by role\nif is_admin:\n    # Show admin panel\n    pass\n```\n\n**Pro tip:** Without Redis, checks go to the controller. Add Redis to cache role lookups (15-minute default TTL).\n\n\u2192 [Complete RBAC example](examples/step-4-rbac.py)  \n\u2192 [AI Fabrix Builder Quick Start](https://github.com/esystemsdev/aifabrix-builder/blob/main/docs/QUICK-START.md)\n\n---\n\n### Step 5: Activate Logging\n\n**What happens:** Application logs are sent to the Miso Controller with client token authentication.\n\n```python\nfrom miso_client import MisoClient, load_config\n\n# Client token is automatically managed - no API key needed\nclient = MisoClient(load_config())\nawait client.initialize()\n\ntoken = client.get_token(req)\nuser = await client.get_user(token)\n\n# Log messages\nawait client.log.info('User accessed dashboard', {'userId': user.id if user else None})\nawait client.log.error('Operation failed', {'error': str(err)})\nawait client.log.warn('Unusual activity', {'details': '...'})\n```\n\n**What happens to logs?** They're sent to the Miso Controller for centralized monitoring and analysis. Client token is automatically included.\n\n\u2192 [Complete logging example](examples/step-5-logging.py)  \n\u2192 [Logging Reference](docs/api-reference.md#logger-service)\n\n---\n\n### Step 6: Activate Audit\n\n**What happens:** Create audit trails for compliance and security monitoring.\n\n```python\nfrom miso_client import MisoClient, load_config\n\n# Complete configuration (all in .env)\nclient = MisoClient(load_config())\nawait client.initialize()\n\ntoken = client.get_token(req)\nis_valid = await client.validate_token(token)\ncan_edit = await client.has_permission(token, 'edit:content')\nuser = await client.get_user(token)\n\n# Audit: User actions\nawait client.log.audit('user.login', 'authentication', {\n    'userId': user.id if user else None,\n    'ip': req.get('ip', ''),\n    'userAgent': req.get('headers', {}).get('user-agent', ''),\n})\n\n# Audit: Content changes\nawait client.log.audit('post.created', 'content', {\n    'userId': user.id if user else None,\n    'postId': 'post-123',\n    'postTitle': req.get('body', {}).get('title', ''),\n})\n\n# Audit: Permission checks\nawait client.log.audit('access.denied', 'authorization', {\n    'userId': user.id if user else None,\n    'requiredPermission': 'edit:content',\n    'resource': 'posts',\n})\n```\n\n**What to audit:** Login/logout, permission checks, content creation/deletion, role changes, sensitive operations.\n\n\u2192 [Complete audit example](examples/step-6-audit.py)  \n\u2192 [Best Practices](docs/getting-started.md#common-patterns)\n\n---\n\n### Encryption and Caching\n\n**What happens:** Use encryption for sensitive data and generic caching for improved performance.\n\n```python\nfrom miso_client import MisoClient, load_config\n\nclient = MisoClient(load_config())\nawait client.initialize()\n\n# Encryption (requires ENCRYPTION_KEY in .env)\nencrypted = client.encrypt('sensitive-data')\ndecrypted = client.decrypt(encrypted)\nprint('Decrypted:', decrypted)\n\n# Generic caching (automatically uses Redis if available, falls back to memory)\nawait client.cache_set('user:123', {'name': 'John', 'age': 30}, 600)  # 10 minutes TTL\nuser = await client.cache_get('user:123')\nif user:\n    print('Cached user:', user)\n```\n\n**Configuration:**\n\n```bash\n# Add to .env\nENCRYPTION_KEY=your-32-byte-encryption-key\n```\n\n\u2192 [API Reference](docs/api-reference.md#encryption-methods)  \n\u2192 [Cache Methods](docs/api-reference.md#cache-methods)\n\n---\n\n## \ud83d\udd27 Configuration\n\n```python\nfrom miso_client import MisoClientConfig, RedisConfig\n\nconfig = MisoClientConfig(\n    controller_url=\"http://localhost:3000\",  # Required: Controller URL\n    client_id=\"ctrl-dev-my-app\",              # Required: Client ID\n    client_secret=\"your-secret\",              # Required: Client secret\n    redis=RedisConfig(                        # Optional: For caching\n        host=\"localhost\",\n        port=6379,\n    ),\n    log_level=\"info\",                         # Optional: 'debug' | 'info' | 'warn' | 'error'\n    cache={                                   # Optional: Cache TTL settings\n        \"role_ttl\": 900,       # Role cache TTL (default: 900s)\n        \"permission_ttl\": 900, # Permission cache TTL (default: 900s)\n    }\n)\n```\n\n**Recommended:** Use `load_config()` to load from `.env` file automatically.\n\n\u2192 [Complete Configuration Reference](docs/configuration.md)\n\n---\n\n## \ud83d\udcda Documentation\n\n- **[Getting Started](docs/getting-started.md)** - Detailed setup guide\n- **[API Reference](docs/api-reference.md)** - Complete API documentation\n- **[Configuration](docs/configuration.md)** - Configuration options\n- **[Examples](docs/examples.md)** - Framework-specific examples\n- **[Troubleshooting](docs/troubleshooting.md)** - Common issues and solutions\n\n---\n\n## \ud83c\udfd7\ufe0f Architecture\n\nThe SDK consists of five core services:\n\n- **AuthService** - Token validation and user authentication\n- **RoleService** - Role management with Redis caching\n- **PermissionService** - Fine-grained permissions\n- **LoggerService** - Centralized logging with API key authentication\n- **RedisService** - Caching and queue management (optional)\n\n\u2192 [Architecture Details](docs/api-reference.md#architecture)\n\n---\n\n## \ud83c\udf10 Setup Your Application\n\n**First time setup?** Use the AI Fabrix Builder:\n\n1. **Create your app:**\n   ```bash\n   aifabrix create myapp --port 3000 --database --language python\n   ```\n\n2. **Login to controller:**\n   ```bash\n   aifabrix login\n   ```\n\n3. **Register your application:**\n   ```bash\n   aifabrix app register myapp --environment dev\n   ```\n\n4. **Start development** and then deploy to Docker or Azure.\n\n\u2192 [Full Quick Start Guide](https://github.com/esystemsdev/aifabrix-builder/blob/main/docs/QUICK-START.md)\n\n---\n\n## \ud83d\udca1 Next Steps\n\n### Learn More\n- [FastAPI Integration](docs/examples.md#fastapi-integration) - Protect API routes\n- [Django Middleware](docs/examples.md#django-middleware) - Django integration\n- [Flask Decorators](docs/examples.md#flask-decorators) - Decorator-based auth\n- [Error Handling](docs/examples.md#error-handling) - Best practices\n\n### Common Tasks\n\n**Add authentication middleware (FastAPI):**\n```python\nfrom fastapi import Depends, HTTPException, Security\nfrom fastapi.security import HTTPBearer\nfrom miso_client import MisoClient\n\nsecurity = HTTPBearer()\nclient = MisoClient(load_config())\n\nasync def get_current_user(credentials = Security(security)):\n    token = credentials.credentials\n    is_valid = await client.validate_token(token)\n    if not is_valid:\n        raise HTTPException(status_code=401, detail=\"Invalid token\")\n    return await client.get_user(token)\n```\n\n**Protect routes by role (FastAPI):**\n```python\n@app.get('/admin')\nasync def admin_panel(user = Depends(get_current_user), credentials = Security(security)):\n    token = credentials.credentials\n    is_admin = await client.has_role(token, 'admin')\n    if not is_admin:\n        raise HTTPException(status_code=403, detail=\"Forbidden\")\n    \n    # Admin only code\n    return {\"message\": \"Admin panel\"}\n```\n\n**Use environment variables:**\n```bash\nMISO_CLIENTID=ctrl-dev-my-app\nMISO_CLIENTSECRET=your-secret\nMISO_CONTROLLER_URL=http://localhost:3000\nREDIS_HOST=localhost\nREDIS_PORT=6379\nMISO_LOG_LEVEL=info\n```\n\n---\n\n## \ud83d\udc1b Troubleshooting\n\n**\"Cannot connect to controller\"**  \n\u2192 Verify `controllerUrl` is correct and accessible  \n\u2192 Check network connectivity\n\n**\"Redis connection failed\"**  \n\u2192 SDK falls back to controller-only mode (slower but works)  \n\u2192 Fix: `aifabrix up` to start Redis\n\n**\"Client token fetch failed\"**  \n\u2192 Check `MISO_CLIENTID` and `MISO_CLIENTSECRET` are correct  \n\u2192 Verify credentials are configured in controller  \n\u2192 Ensure `ENCRYPTION_KEY` environment variable is set (required for encryption service)\n\n**\"Token validation fails\"**  \n\u2192 Ensure Keycloak is running and configured correctly  \n\u2192 Verify token is from correct Keycloak instance  \n\u2192 Check that `python-dotenv` is installed if using `.env` files\n\n\u2192 [More Help](docs/troubleshooting.md)\n\n---\n\n## \ud83d\udce6 Installation\n\n```bash\n# pip\npip install miso-client\n\n# Development mode\npip install -e .\n\n# With dev dependencies\npip install \"miso-client[dev]\"\n```\n\n---\n\n## \ud83d\udd17 Links\n\n- **GitHub Repository**: [https://github.com/esystemsdev/aifabrix-miso-client-python](https://github.com/esystemsdev/aifabrix-miso-client-python)\n- **PyPI Package**: [https://pypi.org/project/miso-client/](https://pypi.org/project/miso-client/)\n- **Builder Documentation**: [https://github.com/esystemsdev/aifabrix-builder](https://github.com/esystemsdev/aifabrix-builder)\n- **Issues**: [https://github.com/esystemsdev/aifabrix-miso-client-python/issues](https://github.com/esystemsdev/aifabrix-miso-client-python/issues)\n\n---\n\n## \ud83d\udcc4 License\n\nThis project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details.\n\n---\n\n**Made with \u2764\ufe0f by eSystems Nordic Ltd.**\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Python client SDK for AI Fabrix authentication, authorization, and logging",
    "version": "0.1.0",
    "project_urls": {
        "Documentation": "https://docs.aifabrix.ai/miso-client-python",
        "Homepage": "https://github.com/aifabrix/miso-client-python",
        "Issues": "https://github.com/aifabrix/miso-client-python/issues",
        "Repository": "https://github.com/aifabrix/miso-client-python"
    },
    "split_keywords": [
        "authentication",
        " authorization",
        " rbac",
        " jwt",
        " redis",
        " logging",
        " aifabrix",
        " miso"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "1f247c76041c47724f39892dfa40b3942e414843166a370027115cebeb4f7523",
                "md5": "42c096609e5cedf25bc56bf88a3fed56",
                "sha256": "9ba0f01fbda8121c35087fd0aa203eb92d5485cf8f4977af491e2b1987537dc6"
            },
            "downloads": -1,
            "filename": "miso_client-0.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "42c096609e5cedf25bc56bf88a3fed56",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 33221,
            "upload_time": "2025-10-30T14:39:24",
            "upload_time_iso_8601": "2025-10-30T14:39:24.332261Z",
            "url": "https://files.pythonhosted.org/packages/1f/24/7c76041c47724f39892dfa40b3942e414843166a370027115cebeb4f7523/miso_client-0.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "bb6d74792c117e9db85ecdaf227b99c419f89c8b373455db9f7bdf69e6ae209a",
                "md5": "eaea3ef7c44ed720790715881186489d",
                "sha256": "a8dab903767be2df5d32acbf73e3867df7e0dae8f4d70db71673d82eed3f3f56"
            },
            "downloads": -1,
            "filename": "miso_client-0.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "eaea3ef7c44ed720790715881186489d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 35535,
            "upload_time": "2025-10-30T14:39:26",
            "upload_time_iso_8601": "2025-10-30T14:39:26.332839Z",
            "url": "https://files.pythonhosted.org/packages/bb/6d/74792c117e9db85ecdaf227b99c419f89c8b373455db9f7bdf69e6ae209a/miso_client-0.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-10-30 14:39:26",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "aifabrix",
    "github_project": "miso-client-python",
    "github_not_found": true,
    "lcname": "miso-client"
}
        
Elapsed time: 1.40359s