🛡️ rajeev02-kavach-sdk
Python Backend Client for Kavach Shield Engine
🔗 Source Code: Rajeev02/kavachid on GitHub
📖 Overview
The official Kavach Python SDK. While the frontend SDKs (React, iOS, Android) handle the user-facing biometrics, this SDK is designed strictly for Backend Microservices (FastAPI, Flask, Django, etc.). It acts as a high-level wrapper to communicate with your central Kavach Shield Engine (KSE) to evaluate user risk in real-time.
✨ Key Features
- Risk Engine Integration: Instantly query the KSE
/v1/kse/evaluateendpoint to determine if an action should be allowed, blocked, or stepped-up. - Async Support: Includes both synchronous (
requests) and fully asynchronous (aiohttp/httpx) clients for high-concurrency FastAPI servers. - Webhook Verification: Cryptographically verifies incoming webhooks from the Kavach SaaS platform using HMAC-SHA256 signatures.
- Telemetry Parsing: Helper methods to parse and validate
x-device-fingerprintheaders sent by frontend clients.
🏆 Why Use This Library?
- Decoupled Security: Keeps complex security logic out of your main business applications. Let the Shield Engine handle the risk matrix.
- Zero-Trust Enforcement: Easily wrap sensitive API routes with decorators that automatically enforce risk policies.
- High Performance: Connection pooling ensures minimal latency overhead when evaluating risk.
🚀 Installation (PyPI)
pip install rajeev02-kavach-sdk
💻 Detailed Usage
1. Basic Risk Evaluation
from kavach.sdk import KavachShieldClient
from kavach.models import ActionType, SecurityLevel
client = KavachShieldClient("https://api.yourdomain.com", api_key="sk_live_123")
def perform_bank_transfer(user_id, amount, request):
# Evaluate the risk BEFORE executing the business logic
decision = client.evaluate(
user_id=user_id,
action_type=ActionType.FINANCIAL_TRANSFER,
security_level=SecurityLevel.CRITICAL,
ip_address=request.client.host,
device_fingerprint=request.headers.get("x-device-fingerprint")
)
if decision.status == "DENY":
raise Exception("Access Denied: High Risk Detected")
elif decision.status == "STEP_UP_REQUIRED":
raise Exception("401 MFA Required: Please provide biometric verification")
# Proceed with transfer if status == "ALLOW"
return "Transfer successful"
2. FastAPI Decorator Example
from fastapi import FastAPI, Depends
from kavach.sdk.fastapi import require_risk_level
app = FastAPI()
@app.post("/api/v1/delete-account")
@require_risk_level(SecurityLevel.CRITICAL)
async def delete_account():
# If the user's current session doesn't meet the risk threshold,
# the decorator automatically returns a 403 or 401 demanding biometrics.
pass
🌐 The Kavach Ecosystem
Kavach provides native SDKs for all major platforms:
| Platform | Source Code (GitHub) | Package Registry |
|---|---|---|
| 🌍 Web | Source Code | NPM: @rajeev02/kavach-web |
| 📱 React Native | Source Code | NPM: @rajeev02/kavach-react-native |
| 🍎 iOS (Swift) | Source Code | CocoaPods: KavachSDK |
| 🤖 Android (Kotlin) | Source Code | Maven: io.github.rajeev02.kavach |
| 🐦 Flutter | Source Code | Pub.dev: kavach_flutter |
| 🐍 Python | Source Code | PyPI: rajeev02-kavach-sdk |
| 🐹 Go | Source Code | pkg.go.dev |
Metadata
Release files for rajeev02-kavach-sdk 1.0.4
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| rajeev02_kavach_sdk-1.0.4.tar.gz | 3.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| rajeev02_kavach_sdk-1.0.4-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 6.2 kB
Release files / rajeev02_kavach_sdk-1.0.4.tar.gz
| Download URL | rajeev02_kavach_sdk-1.0.4.tar.gz |
|---|---|
| Size | 3.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
642185ac9bde708f81dd589970cc19b06f7b90572f76e1b6f956b3d7bdef75b9
|
|
BLAKE2b-256 checksum How to use checksums |
12ced1ff9b8a1f5cc0dba6cc7902227e6c3945f01e8824adac54d5cf73340a28
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.5
|
Release files / rajeev02_kavach_sdk-1.0.4-py3-none-any.whl
| Download URL | rajeev02_kavach_sdk-1.0.4-py3-none-any.whl |
|---|---|
| Size | 3.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
cc04d24dbd15dc2c7596f23ff33f08ffdf29779dafc963dae6e71ab6977dd510
|
|
BLAKE2b-256 checksum How to use checksums |
dafb2850921a24abdd1396e72af36712d9779e618f5b180ded5c61076a222897
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.5
|