Skip to content

Advanced Security Decorators

Advanced security decorators offer sophisticated controls including time-based access rules, honeypots, and suspicious pattern detection control.


Time-Based Access Control

from djangoapi_guard import SecurityDecorator
from django.http import JsonResponse

guard_deco = SecurityDecorator(config)

@guard_deco.time_window("09:00", "17:00", "EST")
def generate_reports(request):
    return JsonResponse({"message": "Reports are only available during business hours"})

Honeypot Protection

@guard_deco.honeypot_detection(trap_fields=["website_url"])
def register_user(request):
    return JsonResponse({"message": "User registered successfully"})

Suspicious Pattern Detection Control

@guard_deco.suspicious_detection(enabled=False)
def submit_code(request):
    return JsonResponse({"status": "Code submitted for review"})

Error Handling

  • 403 Forbidden: Outside allowed time window, honeypot field filled

Next Steps

For complete API reference, see the Advanced Decorators API Documentation.