Skip to main content

Python Auth SDK for AI tool integration with the Noesis AIToolCenter platform

Project description

noesis-auth (Python)

Python Auth SDK for AI tool integration with the Noesis AIToolCenter platform.

Installation

pip install noesis-auth

# With FastAPI middleware support:
pip install noesis-auth[fastapi]

Quick Start

JWT Validation (Tool-side)

from auth_sdk import JWTValidator

validator = JWTValidator(
    jwks_url="https://your-platform.com/.well-known/jwks.json"
)

payload = await validator.validate(token)
print(payload["sub"])  # user ID

FastAPI Middleware

from fastapi import Depends, FastAPI
from auth_sdk import AuthMiddleware, TokenPayload

app = FastAPI()
auth = AuthMiddleware(jwks_url="https://your-platform.com/.well-known/jwks.json")

@app.get("/api/generate")
async def generate(payload: TokenPayload = Depends(auth.require_tool("your-tool-id"))):
    user_id = payload.sub
    # ... your tool logic

OAuth2 Client (PKCE)

from auth_sdk import AuthClient

client = AuthClient(base_url="https://your-platform.com")

# Generate PKCE pair
pkce = AuthClient.generate_pkce()

# Build authorization URL
url = client.build_authorize_url(
    client_id="your-client-id",
    redirect_uri="http://localhost:3000/callback",
    code_challenge=pkce.code_challenge,
)

# Exchange code for tokens
tokens = await client.exchange_code(
    code=auth_code,
    redirect_uri="http://localhost:3000/callback",
    client_id="your-client-id",
    code_verifier=pkce.code_verifier,
)

Activation Code Redemption

result = await client.redeem_code(user_token="...", code="AXKF-M3PQ-7RBN-W2YT")
print(result.tool_id, result.expires_at)

Features

  • JWT Validation — RS256 (JWKS) and HS256 (shared secret) with auto-detection
  • FastAPI Middleware — Drop-in authentication and tool access verification
  • OAuth2 Client — Authorization URL builder, code exchange, token refresh
  • PKCE Support — S256 code challenge generation for public clients
  • Token Introspection — Remote token validation endpoint
  • Activation Codes — Redeem activation codes for tool entitlements
  • JWKS Caching — 6-hour cache with stale-while-revalidate and retry on failure

Requirements

  • Python >= 3.11
  • httpx >= 0.24
  • python-jose[cryptography] >= 3.3
  • fastapi >= 0.100 (optional, for middleware)

License

MIT

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

noesis_auth-0.1.0.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

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

noesis_auth-0.1.0-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file noesis_auth-0.1.0.tar.gz.

File metadata

  • Download URL: noesis_auth-0.1.0.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for noesis_auth-0.1.0.tar.gz
Algorithm Hash digest
SHA256 7f600e856056552e9a47625c46e2ea9074d65c6b6eea6b4af6e12d8da015e8b3
MD5 69e771ad0c26ef717b4094d676f993af
BLAKE2b-256 0788dfb4f20487c3f44b4d3db3a3042c49db6fb45ae140ed743a1149c0098103

See more details on using hashes here.

File details

Details for the file noesis_auth-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: noesis_auth-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.15

File hashes

Hashes for noesis_auth-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1a94826f7b6da4360e9306177ead66bccb4fdd9fcf9322e73a893998d6311972
MD5 1cec9ac92854fdd7e0bf0025dfe3c463
BLAKE2b-256 eae394dc300e78fee709b24bd2799c5120365abf48f7b124e031aea9086a2541

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