[elbe-devel] [PATCH] Allow Basic HTTP authentication for repo-keys
Türk, Jan
Jan.Tuerk at emtrion.de
Thu Jan 24 18:42:05 CET 2019
Patch was made against v2.9.9 sorry I'll prepare a new one.
>
> diff --git a/elbepack/rfs.py b/elbepack/rfs.py index 4aede388..c1e1b9d8 100644
> --- a/elbepack/rfs.py
> +++ b/elbepack/rfs.py
> @@ -204,8 +204,24 @@ class BuildEnv ():
> if self.xml.has('project/mirror/url-list'):
> for url in self.xml.node('project/mirror/url-list'):
> if url.has('key'):
> +
> + passman = urllib2.HTTPPasswordMgrWithDefaultRealm()
> + authhandler = urllib2.HTTPBasicAuthHandler(passman)
> + opener = urllib2.build_opener(authhandler)
> + urllib2.install_opener(opener)
> +
> keyurl = url.text('key').strip() # URL to key
> - name = keyurl.split('/')[-1] # Filename of key
> + if '@' in keyurl:
> + t = keyurl.split('@')
> + if '://' in t[0]:
> + scheme, auth = t[0].split('://')
> + scheme = scheme + '://'
> + else:
> + scheme = ''
> + auth = t[0]
> + keyurl = scheme + t[1]
> + usr, passwd = auth.split(':')
> + passman.add_password(None, keyurl, usr, passwd)
>
> myKey = urllib2.urlopen(keyurl).read()
> self.log.do(
-------------- next part --------------
A non-text attachment was scrubbed...
Name: winmail.dat
Type: application/ms-tnef
Size: 4599 bytes
Desc: not available
URL: <http://lists.linutronix.de/pipermail/elbe-devel/attachments/20190124/7aee2d1f/attachment.bin>
More information about the elbe-devel
mailing list