INNER CODE UNIT · Python

consume_auth_ticket

MakazhanAlpamys/Soup · src/soup_cli/ui/app.py:337

def consume_auth_ticket(ticket: str) -> bool:
    """Consume a single-use ticket if valid and unexpired."""
    if not ticket:
        return False
    now = time.time()
    with _tickets_lock:
        _cleanup_expired_tickets()
        exp = _tickets.pop(ticket, None)
        if exp is not None and now <= exp:
            return True
    return False


def _bearer_matches(header_value: str) -> bool:
    """Verify Bearer token against configured token in constant time.

    Encodes both values to UTF-8 bytes before comparing, because
    secrets.compare_digest raises TypeError if passed non-ASCII str arguments

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…