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

Jan Tuerk jan.tuerk at emtrion.com
Thu Jan 24 18:13:05 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, 17 insertions(+), 1 deletion(-)

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(
-- 
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