The first patch is the latest version of my auth patch, with an updated test including a few more cases. The second fixes an import warning in util.py, which happens if the initial import (of md5 or sha) fails and 'global' is then used on an already used symbol.