def _scrub_headers(headers):
    """scrub auth info from headers"""
    headers = dict(headers)
    if 'Authorization' in headers:
        auth = headers['Authorization']
        if ' ' in auth:
            auth_type = auth.split(' ', 1)[0]
        else:
            # no space, hide the whole thing in case there was a mistake
            auth_type = ''
        headers['Authorization'] = f'{auth_type} [secret]'
    if 'Cookie' in headers:
        try:
            c = SimpleCookie(headers['Cookie'])
        except Exception as e:
            # it's possible for browsers to send invalid cookies
            headers['Cookie'] = f"Invalid Cookie: {e}"
        else:
            redacted = []
            for name in c.keys():
                redacted.append(f"{name}=[secret]")
            headers['Cookie'] = '; '.join(redacted)
    return headers
scrub auth info from headers
jupyterhub/log.py