Parse rfc2617 HTTP authentication header string (basic) and return (user,pass) tuple or None
(header)
| 1876 | |
| 1877 | |
| 1878 | def parse_auth(header): |
| 1879 | """ Parse rfc2617 HTTP authentication header string (basic) and return (user,pass) tuple or None""" |
| 1880 | try: |
| 1881 | method, data = header.split(None, 1) |
| 1882 | if method.lower() == 'basic': |
| 1883 | #TODO: Add 2to3 save base64[encode/decode] functions. |
| 1884 | user, pwd = touni(base64.b64decode(tob(data))).split(':',1) |
| 1885 | return user, pwd |
| 1886 | except (KeyError, ValueError): |
| 1887 | return None |
| 1888 | |
| 1889 | |
| 1890 | def _lscmp(a, b): |