Skip to content

HTTP basic auth is broken for accented characters #301

Closed
@adrienverge

Description

@adrienverge

Username/password encoding in HTTP basic auth is currently broken for non-ASCII password.

Example with user user and password unusual-char-é. With curl it works as expected:

curl -v 'http://user:unusual-char-%C3%A9@localhost:5984/'
> GET / HTTP/1.1
> Authorization: Basic YWxpY2U6YWRyaWVuPTohw6k=
> 
< HTTP/1.1 200 OK

But with couchdb-python the string is decoded from utf-8 then re-encoded into latin1, causing an incorrect Authorization header:

url = 'http://user:unusual-char-%C3%A9@localhost:5984/'
couchdb.Server(url).version()
> GET / HTTP/1.1
> Authorization: Basic dXNlcjp1bnVzdWFsLWNoYXIt6Q==
> 
< HTTP/1.1 401 Unauthorized

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions