INNER CODE UNIT · Python
_allow
Kounex/obs_blade · tool/kick_auth_proxy/proxy.py:84
def _allow(ip: str, now: float | None = None) -> bool:
moment = time.monotonic() if now is None else now
bucket = _hits[ip]
while bucket and moment - bucket[0] > WINDOW_SECONDS:
bucket.popleft()
if len(bucket) >= MAX_PER_WINDOW:
return False
bucket.append(moment)
return True
def build_upstream(form: dict[str, str]) -> dict[str, str]:
"""Return the form Kick should see, or raise ProxyError."""
if not CLIENT_ID or not CLIENT_SECRET:
raise ProxyError(500, "not_configured")
grant = form.get("grant_type", "")
if grant == "authorization_code":
code = form.get("code", "")