elasticsearch-py
elasticsearch-py copied to clipboard
Passwords in basic auth can't be non latin-1
When passing basic auth headers the client calls:
b64encode(b(basic_auth)).decode('utf-8') via the urllib3 request package.
Here b is defined as
def b(s):
return s.encode("latin-1")
This causes any non latin-1 to be encoded incorrectly and prevents auth.
Current solution is to use a custom class for the auth pair i.e.
class UTFBasicAuth():
def __init__(self, username, password):
self.username = username
self.password = password
def encode(self, encoding):
return ('%s:%s' % (self.username, self.password)).encode('utf-8')
@gingerwizard thanks for opening this issue, I was able to reproduce this by adding a user with an á character in the password and then attempting to make a request via the elasticsearch-py library. I'll do some more investigation to come up with a suitable fix.