Skip to main content

Official Django integration for Traffic Orchestrator license validation

Project description

django-traffic-orchestrator

Official Django integration for Traffic Orchestrator.

📖 API Reference · SDK Guides · OpenAPI Spec

Install

pip install django-traffic-orchestrator

Configuration

# settings.py
INSTALLED_APPS = [
    'traffic_orchestrator.django',
]

TRAFFIC_ORCHESTRATOR = {
    'API_KEY': os.environ.get('TO_API_KEY'),
    'TIMEOUT': 5,
    'RETRIES': 3,
}

Middleware (Automatic License Checking)

# settings.py
MIDDLEWARE = [
    'traffic_orchestrator.django.middleware.LicenseMiddleware',
    # ...
]

Decorator

from traffic_orchestrator.django.decorators import require_license

@require_license(plan='pro')
def premium_view(request):
    return JsonResponse({'access': 'granted'})

Template Tag

{% load traffic_orchestrator %}
{% if_licensed 'pro' %}
  <div>Premium content</div>
{% endif_licensed %}

API Methods

Method/Decorator Auth Description
@require_license(plan) Yes View decorator — restrict by plan
{% if_licensed %} Yes Template tag — conditional content
validate_license(token, domain) No Validate a license key
verify_offline(token) No Ed25519 offline verification
list_licenses() Yes List all licenses
create_license(options) Yes Create a new license
add_domain(id, domain) Yes Add domain to license
remove_domain(id, domain) Yes Remove domain from license
get_usage() Yes Get usage statistics
health_check() No Check API health

Multi-Environment

# settings.py
TRAFFIC_ORCHESTRATOR = {
    'API_KEY': os.environ.get('TO_API_KEY'),
    # Staging
    'API_URL': os.environ.get('TO_API_URL', 'https://api.trafficorchestrator.com/api/v1'),
}

Offline Verification (Enterprise)

Validate licenses locally without API calls using Ed25519 JWT signatures:

# settings.py
TRAFFIC_ORCHESTRATOR = {
    'PUBLIC_KEY': os.environ.get('TO_PUBLIC_KEY'),
}

# views.py
from traffic_orchestrator.django import verify_offline

result = verify_offline(license_token)
if result.valid:
    print(f"Plan: {result.plan_id}")

Requirements

  • Python 3.8+
  • Django 4.0+

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

traffic_orchestrator_django-2.0.0.tar.gz (8.5 kB view details)

Uploaded Source

Built Distribution

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

traffic_orchestrator_django-2.0.0-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

Details for the file traffic_orchestrator_django-2.0.0.tar.gz.

File metadata

File hashes

Hashes for traffic_orchestrator_django-2.0.0.tar.gz
Algorithm Hash digest
SHA256 a65da7aaf52e586753621ec241756ee4bc0389fb667236890957d4e54c1c8b7f
MD5 4ef89cf47f4ce87898a784c43ef81815
BLAKE2b-256 ec2c3e8497e8a7c4ddec57508e9078d42288d66d024586b12d6a716bf382d2a5

See more details on using hashes here.

File details

Details for the file traffic_orchestrator_django-2.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for traffic_orchestrator_django-2.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9639c6d792393647284c253aeceac40dd8a210736688ec49f877e725257f8372
MD5 23e663d2c9ce14978c21397ff4df5899
BLAKE2b-256 ca7bc92f13a30f2da9dacc0040fd5789d65b0dba3be47d3e8616e875e2a37ab1

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