This repository has been archived on 2020-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
quay/util/headers.py

20 lines
457 B
Python
Raw Normal View History

import base64
def parse_basic_auth(header_value):
""" Attempts to parse the given header value as a Base64-encoded Basic auth header. """
if not header_value:
return None
parts = header_value.split(' ')
if len(parts) != 2 or parts[0].lower() != 'basic':
return None
try:
2015-05-18 19:01:37 +00:00
basic_parts = base64.b64decode(parts[1]).split(':')
if len(basic_parts) != 2:
return None
return basic_parts
except ValueError:
return None