INNER CODE UNIT · Python

_consume_auth_header

Far-Se/tabame · plugins/api-client/main.py:357

def _consume_auth_header(headers):
    """Pull an Authorization header out into authType/authToken/authUser/authPass, if present."""
    auth_type, token, user, pw = "none", "", "", ""
    for k, v in list(headers.items()):
        if k.lower() == "authorization" and isinstance(v, str):
            if v.lower().startswith("bearer "):
                auth_type, token = "bearer", v[7:].strip()
                del headers[k]
            elif v.lower().startswith("basic "):
                auth_type = "basic"
                try:
                    decoded = base64.b64decode(v[6:].strip()).decode("utf-8", "replace")
                    if ":" in decoded:
                        user, pw = decoded.split(":", 1)
                except Exception:
                    pass
                del headers[k]
            break

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…