Skip to content
This repository has been archived by the owner on Jul 22, 2019. It is now read-only.

More user friendly for HTTP Basic Auth #318

Closed
zachcheung opened this issue May 1, 2017 · 2 comments
Closed

More user friendly for HTTP Basic Auth #318

zachcheung opened this issue May 1, 2017 · 2 comments

Comments

@zachcheung
Copy link

In [1]: from couchdb.http import extract_credentials

In [2]: from urllib.parse import urlsplit

In [3]: url = 'http://joe:secret_has_#_@localhost:5984/_config/'

In [4]: extract_credentials(url)
Out[4]: ('http://joe:secret_has_#_@localhost:5984/_config/', None)

In [5]: urlsplit(url)
Out[5]: SplitResult(scheme='http', netloc='joe:secret_has_', path='', query='', fragment='_@localhost:5984/_config/')

Error happened when I used couchdb-python with random generated password which has number sign #. I realized that I should quote password firstly, but I thought it's not very user-friendly, quote password manually and unquoted by couchdb-python, why not just add user, password parameters or auth like Requests?

To avoid modify related codes, I implement as blow but still think not a proper way to handle it:

>>> extract_credentials('http://joe@example.com:secret_has_special_chars_@#!:_@localhost:5984/_config/')
('http://localhost:5984/_config/', ('joe@example.com', 'secret_has_special_chars_@#!:_'))

Any suggestion?

@djc
Copy link
Owner

djc commented May 7, 2017

So what would you propose exactly? I think the current way is pretty pragmatic, and fits in with the design of CouchDB-Python being a fairly light-weight wrapper over het HTTP API.

@zachcheung
Copy link
Author

@djc You're right. I think add auth parameter like requests is more user-friendly, but I'm afraid it'll break current case, so please just ignore this issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants