Changeset - bd1c1fa6524b
[Not reviewed]
stable
0 1 0
Mads Kiilerich (kiilerix) - 5 years ago 2020-05-10 16:32:34
mads@kiilerich.com
auth: simplify handling of Crowd json response (Issue #370)

Correct error where Crowd authentication didn't work due to urllib.readlines()
returning bytes and thus failing to be joined with a string.

json.loads is however happy to take bytes directly.

Fix error handling to also handle bytes without crashing.
1 file changed with 3 insertions and 3 deletions:
0 comments (0 inline, 0 general) First comment
kallithea/lib/auth_modules/auth_crowd.py
Show inline comments
 
@@ -94,10 +94,10 @@ class CrowdServer(object):
 
            req.get_method = lambda: method
 

	
 
        global msg
 
        msg = ""
 
        msg = None
 
        try:
 
            rdoc = self.opener.open(req)
 
            msg = "".join(rdoc.readlines())
 
            msg = rdoc.read()
 
            if not msg and empty_response_ok:
 
                rval = {}
 
                rval["status"] = True
 
@@ -111,7 +111,7 @@ class CrowdServer(object):
 
            if not noformat:
 
                rval = {"status": False,
 
                        "body": body,
 
                        "error": str(e) + "\n" + msg}
 
                        "error": "%s\n%r" % (e, msg)}
 
            else:
 
                rval = None
 
        return rval
0 comments (0 inline, 0 general) First comment
You need to be logged in to comment. Login now