[elbe-devel] [PATCH v2] Allow Basic HTTP authentication for repo-keys

Jan Tuerk jan.tuerk at emtrion.com
Fri Jan 25 14:38:38 CET 2019


The key-retrieval for apt-repostiories, protected by HTTP basic auth,
leads to an elbe-crash.
This patch adds the support for basic-auth, to receive the key,
as introduced with commit: a0a9914d8cbced6c6afe9ef8ad9552db9f2ea9b8
for the repository itself.

Signed-off-by: Jan Tuerk <jan.tuerk at emtrion.com>
---
 elbepack/rfs.py | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)

diff --git a/elbepack/rfs.py b/elbepack/rfs.py
index eec4e6a0..fa9b5478 100644
--- a/elbepack/rfs.py
+++ b/elbepack/rfs.py
@@ -209,9 +209,27 @@ class BuildEnv (object):
         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
                     keyurl = keyurl.replace('LOCALMACHINE', '10.0.2.2')
 
+                    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(
                         'echo "%s" > %s' %
-- 
emtrion GmbH
Alter Schlachthof 45
76131 Karlsruhe
GERMANY
https://www.emtrion.de

Amtsgericht Mannheim
HRB 110 300
Geschäftsführer: Dieter Baur, Ramona Maurer




More information about the elbe-devel mailing list