Revision 716a32cb lib/http/auth.py
b/lib/http/auth.py | ||
---|---|---|
28 | 28 |
import binascii |
29 | 29 |
|
30 | 30 |
from ganeti import utils |
31 |
from ganeti import compat |
|
31 | 32 |
from ganeti import http |
32 | 33 |
|
33 | 34 |
from cStringIO import StringIO |
34 | 35 |
|
35 |
try: |
|
36 |
from hashlib import md5 |
|
37 |
except ImportError: |
|
38 |
from md5 import new as md5 |
|
39 |
|
|
40 |
|
|
41 | 36 |
# Digest types from RFC2617 |
42 | 37 |
HTTP_BASIC_AUTH = "Basic" |
43 | 38 |
HTTP_DIGEST_AUTH = "Digest" |
... | ... | |
271 | 266 |
# There can not be a valid password for this case |
272 | 267 |
raise AssertionError("No authentication realm") |
273 | 268 |
|
274 |
expha1 = md5()
|
|
269 |
expha1 = compat.md5_hash()
|
|
275 | 270 |
expha1.update("%s:%s:%s" % (username, realm, password)) |
276 | 271 |
|
277 | 272 |
return (expected_password.lower() == expha1.hexdigest().lower()) |
Also available in: Unified diff