Python client for the Identora authorizer (OIDC + RBAC)
Project description
cl4im
Python client for the Identora authorizer — handles app authentication, JWT validation, permission checking and automatic operation sync.
Installation
pip install cl4im
# With FastAPI support
pip install "cl4im[fastapi]"
Quick start with FastAPI
from fastapi import FastAPI, Request
from cl4im.adapters.fastapi import Cl4im, operation
app = FastAPI()
cl4im = Cl4im(
app,
authorizer_url="http://localhost:4000/api",
app_id="your-app-uuid",
secret="your-app-secret",
)
@app.get("/public")
@operation(id="public.info", level="public")
async def public_info():
"""Anyone can call this — no token needed."""
return {"message": "Hello, world!"}
@app.get("/items")
@operation(id="items.list", level="private")
async def list_items(request: Request):
"""Requires any authenticated user (token with non-empty groups)."""
user = request.state.user # TokenClaims
return {"user": user.sub, "items": []}
@app.delete("/items/{item_id}")
@operation(id="items.delete", level="protected")
async def delete_item(item_id: str, request: Request):
"""Requires a user whose group has explicit permission for items.delete."""
return {"deleted": item_id}
Standalone client
import asyncio
from cl4im import Cl4imClient, OperationDescriptor
client = Cl4imClient(
authorizer_url="http://localhost:4000/api",
app_id="your-app-uuid",
secret="your-app-secret",
)
client.register_operation(
OperationDescriptor(identifier="items.list", method="read", level="private")
)
async def main():
await client.startup()
# Validate a token from an incoming request
claims = await client.validate_token("<bearer-token>")
# Check whether the token has permission
allowed = client.check_permission(claims, "items.list", "read")
print(f"Allowed: {allowed}")
asyncio.run(main())
Operation levels
| Level | Who can access |
|---|---|
public |
Everyone — no token required |
private |
Any authenticated user (token with at least one group) |
protected |
Only users whose groups intersect the operation's allowed_groups |
Method auto-detection
The @operation decorator infers the method from the function name:
| Function name prefix/keyword | Detected method |
|---|---|
get_, list_, fetch_, read_ |
read |
delete_, remove_, destroy_ |
delete |
contains stream, subscribe, watch |
stream |
| anything else | write |
Configuration
| Parameter | Description |
|---|---|
authorizer_url |
Base URL of Identora, including the API prefix (e.g. http://host/api) |
app_id |
UUID of the app registered in auth.apps |
secret |
Plain-text app secret (never committed — use env vars) |
import os
from cl4im.adapters.fastapi import Cl4im
cl4im = Cl4im(
app,
authorizer_url=os.environ["AUTHORIZER_URL"],
app_id=os.environ["APP_ID"],
secret=os.environ["APP_SECRET"],
)
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
cl4im-0.2.1.tar.gz
(16.3 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
cl4im-0.2.1-py3-none-any.whl
(16.7 kB
view details)
File details
Details for the file cl4im-0.2.1.tar.gz.
File metadata
- Download URL: cl4im-0.2.1.tar.gz
- Upload date:
- Size: 16.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d923e47e97c00770f123e00604fbb2e02812b7567c1584793a02e3c5fe2dcc9c
|
|
| MD5 |
00c4d65dbfa1182735d2f27531ebc539
|
|
| BLAKE2b-256 |
09b9a23bd55e8a55d3152d7cb166d34fc0dc12274eac6b8a6a323c823b67bd41
|
File details
Details for the file cl4im-0.2.1-py3-none-any.whl.
File metadata
- Download URL: cl4im-0.2.1-py3-none-any.whl
- Upload date:
- Size: 16.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3f235273a3c03ad07f73fb195880c9deef03b78bd3b51caf21c9eeacdba3dfe4
|
|
| MD5 |
b215983174585e3c0be22b4798a05ad5
|
|
| BLAKE2b-256 |
066981d7f28f814dd1b2cc659c200d8090c86561bded01fd2a65a87476158ff1
|