(headers)
| 24 | |
| 25 | |
| 26 | def extract_basic_authorization(headers): |
| 27 | auth = headers.get("Authorization") |
| 28 | if not auth or " " not in auth: |
| 29 | return None, None |
| 30 | |
| 31 | auth_type, auth_token = auth.split(None, 1) |
| 32 | if auth_type.lower() != "basic": |
| 33 | return None, None |
| 34 | |
| 35 | try: |
| 36 | query = to_unicode(base64.b64decode(auth_token)) |
| 37 | except (binascii.Error, TypeError): |
| 38 | return None, None |
| 39 | if ":" in query: |
| 40 | username, password = query.split(":", 1) |
| 41 | return unquote(username), unquote(password) |
| 42 | return query, None |
no test coverage detected
searching dependent graphs…