RateLimitConfig (ratelimiting/config.py)

saas-boilerplate · packages/backend/common/ratelimiting/config.py · python · MIT
auth, Auth / Identity, auth / identity

Centralized Django rate‑limit configuration with tiered limits and helper functions.

# Source: https://github.com/apptension/saas-boilerplate | License: MIT | Copyright 2023 Apptension
# Provided via justclaw.it.com; keep this notice with the code.
"""
Rate Limiting Configuration.

Centralized configuration for all rate limits in the application.
All limits are environment-configurable via Django settings.

Usage:
    from common.ratelimiting import get_rate_limit, RateLimitCategory

    # Get a configured rate limit
    rate = get_rate_limit(RateLimitCategory.AUTH_LOGIN)  # Returns '30/min'

    # Get rate limit for a specific tier
    rate = get_rate_limit(RateLimitCategory.AI_CHAT_MESSAGE, tier='power')  # Returns '20/min'
"""

import logging
from dataclasses import dataclass, field
from typing import Dict, Optional

from django.conf import settings

from .constants imp

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key