Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
mercurial
hg-git
Commits
2134f15729dd
Commit
2134f157
authored
Dec 19, 2020
by
Dan Villiom Podlaski Christiansen
Browse files
http: proxy authentication
parent
cdf0388f5ffd
Pipeline
#20786
passed with stages
in 12 minutes and 15 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
hggit/git_handler.py
View file @
2134f157
...
...
@@ -156,6 +156,8 @@
# tried an unauthenticated request, gotten a realm, and are now
# ready to prompt the user, if necessary
self
.
_http_auth_realm
=
None
# same, but for the HTTP proxy
self
.
_http_proxy_realm
=
None
@
property
def
vfs
(
self
):
...
...
@@ -1275,9 +1277,7 @@
self
.
_http_auth_realm
=
m
.
group
(
1
)
elif
'unexpected http resp 407'
in
e
.
args
[
0
]:
raise
error
.
Abort
(
b
'HTTP proxy requires authentication'
,
)
self
.
_http_proxy_realm
=
'Proxy'
# dulwich 0.19
elif
'unexpected http resp 401'
in
e
.
args
[
0
]:
self
.
_http_auth_realm
=
'Git'
...
...
@@ -1820,4 +1820,6 @@
config
=
dul_config
.
ConfigDict
()
config
.
set
(
b
'http'
,
b
'useragent'
,
ua
)
pwmgr
=
url
.
passwordmgr
(
self
.
ui
,
self
.
ui
.
httppasswordmgrdb
)
proxy
=
compat
.
config
(
self
.
ui
,
b
'string'
,
b
'http_proxy'
,
b
'host'
)
...
...
@@ -1823,2 +1825,3 @@
proxy
=
compat
.
config
(
self
.
ui
,
b
'string'
,
b
'http_proxy'
,
b
'host'
)
if
proxy
:
...
...
@@ -1824,3 +1827,9 @@
if
proxy
:
config
.
set
(
b
'http'
,
b
'proxy'
,
b
'http://'
+
proxy
)
# support proxy authentication by injecting it into the URL
proxyuser
=
compat
.
config
(
self
.
ui
,
b
'string'
,
b
'http_proxy'
,
b
'user'
,
)
proxypasswd
=
compat
.
config
(
self
.
ui
,
b
'string'
,
b
'http_proxy'
,
b
'passwd'
,
)
...
...
@@ -1826,6 +1835,14 @@
if
compat
.
config
(
self
.
ui
,
b
'string'
,
b
'http_proxy'
,
b
'passwd'
):
self
.
ui
.
warn
(
b
"warning: proxy authentication is unsupported
\n
"
,
if
proxyuser
:
proxyurl
=
b
'http://%s@%s'
%
(
proxyuser
,
proxy
)
else
:
proxyurl
=
b
'http://'
+
proxy
if
self
.
_http_proxy_realm
:
proxyuser
,
proxypasswd
=
map
(
pycompat
.
bytesurl
,
pwmgr
.
find_user_password
(
self
.
_http_proxy_realm
,
pycompat
.
strurl
(
proxyurl
),
),
)
...
...
@@ -1830,5 +1847,12 @@
)
if
proxyuser
and
proxypasswd
:
proxyurl
=
b
'http://%s:%s@%s'
%
(
proxyuser
,
proxypasswd
,
proxy
,
)
config
.
set
(
b
'http'
,
b
'proxy'
,
proxyurl
)
if
pycompat
.
ispy3
:
# urllib3.util.url._encode_invalid_chars() converts the path
# back to bytes using the utf-8 codec
...
...
@@ -1836,8 +1860,6 @@
else
:
str_uri
=
uri
pwmgr
=
url
.
passwordmgr
(
self
.
ui
,
self
.
ui
.
httppasswordmgrdb
)
# not available in dulwich 0.19, used on Python 2.7
if
hasattr
(
client
,
'get_credentials_from_store'
):
urlobj
=
hgutil
.
url
(
uri
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment