From ca160e778fb7348ca55700f58531c1377f25ddb7 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Chibon Date: Jul 29 2015 15:45:47 +0000 Subject: Be more careful with the data retrieved - Ensure we got something back ('\n'.join(None) doesn't work) - Ensure that something is a list or a tuple (otherwise '\n'.join() won't work either - Ensure all the element of the list have something - Ensure there is something left at the end --- diff --git a/pagure/flask_fas_openid.py b/pagure/flask_fas_openid.py index e4b4219..7defe60 100644 --- a/pagure/flask_fas_openid.py +++ b/pagure/flask_fas_openid.py @@ -147,8 +147,17 @@ class FAS(object): # pragma: no cover # The groups do not contain the cla_ groups user['groups'] = frozenset(teams_resp.teams) if ax_resp: - user['ssh_key'] = '\n'.join( - ax_resp.get('http://fedoauth.org/openid/schema/SSH/key')) + ssh_keys = ax_resp.get( + 'http://fedoauth.org/openid/schema/SSH/key') + if isinstance(ssh_keys, (list, tuple)): + ssh_keys = '\n'.join( + ssh_key + for ssh_key in ssh_keys + if ssh_key.strip() + ) + if ssh_keys: + user['ssh_key'] = ssh_keys + flask.session['FLASK_FAS_OPENID_USER'] = user flask.session.modified = True if self.postlogin_func is not None: