Username and password support in proxy auth.
This commit is contained in:
parent
1aee1232f7
commit
94bd49aa37
@ -239,7 +239,9 @@ Shell completion scripts for Bash, Fish and Zsh can be found in respective subdi
|
||||
- --stag : search bookmarks by a tag, or show all tags alphabetically (if no arguments).
|
||||
- Search results are indexed serially. This index is different from actual database index of a bookmark record which is shown in bold within `[]` after the URL.
|
||||
- **Encryption** is optional and manual. AES256 algorithm is used. To use encryption, the database file should be unlocked (-k) before using buku and locked (-l) afterwards. Between these 2 operations, the database file lies unencrypted on the disk, and NOT in memory. Also, note that the database file is *unencrypted on creation*.
|
||||
- **Proxy** support: environment variable *https_proxy*, if defined, is used to tunnel data for both http and https connections. The supported format is `http[s]://proxyhost:proxyport/`.
|
||||
- **Proxy** support: environment variable *https_proxy*, if defined, is used to tunnel data for both http and https connections. The supported format is:
|
||||
|
||||
http[s]://[username:password@]proxyhost:proxyport/
|
||||
|
||||
## GUI integration
|
||||
|
||||
|
2
buku.1
2
buku.1
@ -228,7 +228,7 @@ Overrides the default browser. Ref:
|
||||
.BI https_proxy
|
||||
If defined, will be used to access http and https resources through the configured proxy. Supported format:
|
||||
|
||||
http[s]://proxyhost:proxyport/
|
||||
http[s]://[username:password@]proxyhost:proxyport/
|
||||
|
||||
.SH EXAMPLES
|
||||
.PP
|
||||
|
21
buku.py
21
buku.py
@ -1498,11 +1498,20 @@ def get_PoolManager():
|
||||
:return: ProxyManager if https_proxy is defined, else PoolManager.
|
||||
'''
|
||||
|
||||
https_proxy = os.environ.get('https_proxy')
|
||||
print(https_proxy)
|
||||
proxy = os.environ.get('https_proxy')
|
||||
|
||||
if https_proxy:
|
||||
return urllib3.ProxyManager(https_proxy)
|
||||
if proxy:
|
||||
headers = None
|
||||
url = urlparse(proxy)
|
||||
# Strip username and password and create header, if present
|
||||
if url.username:
|
||||
proxy = proxy.replace(url.username + ':' + url.password + '@', '')
|
||||
headers = urllib3.util.make_headers(
|
||||
basic_auth=url.username + ':' + url.password
|
||||
)
|
||||
|
||||
logger.debug('proxy: [%s]' % proxy)
|
||||
return urllib3.ProxyManager(proxy, headers=headers)
|
||||
|
||||
return urllib3.PoolManager()
|
||||
|
||||
@ -1914,6 +1923,10 @@ def open_in_browser(url):
|
||||
|
||||
url = url.replace('%22', '\"')
|
||||
if not urlparse(url).scheme:
|
||||
# Prefix with 'http://' is no scheme
|
||||
# Otherwise, opening in browser fails anyway
|
||||
# We expect http to https redirection
|
||||
# will happen for https-only websites
|
||||
logger.error('scheme missing in URI, trying http')
|
||||
url = '%s%s' % ('http://', url)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user