support unicode input on Python 2

py2 unicode == py3 str, and should be treated the same.

Before this patch, `authenticate(u'user', u'password')` would return False with a correct username and password.