From 5569c058c1e08aa5baca58248d409c50c20ef727 Mon Sep 17 00:00:00 2001 From: Mike Bonnet Date: Dec 01 2015 23:51:53 +0000 Subject: print the correct authentication method in "koji moshimoshi" --- diff --git a/cli/koji b/cli/koji index 6724304..42bce30 100755 --- a/cli/koji +++ b/cli/koji @@ -6675,7 +6675,7 @@ def handle_moshimoshi(options, session, args): "Introduce yourself" usage = _("usage: %prog moshimoshi [options]") parser = OptionParser(usage=usage) - (options, args) = parser.parse_args(args) + (opts, args) = parser.parse_args(args) if len(args) != 0: parser.error(_("This command takes no arguments")) assert False @@ -6687,9 +6687,13 @@ def handle_moshimoshi(options, session, args): print "%s, %s!" % (random.choice(greetings), u["name"],) print "" print "You are using the hub at %s" % (session.baseurl,) - if u.get("krb_principal", None) is not None: - print "Authenticated via Kerberos principal %s" % (u["krb_principal"]) - + authtype = u.get("authtype") + if authtype == koji.AUTHTYPE_NORMAL: + print "Authenticated via password" + elif authtype == koji.AUTHTYPE_KERB: + print "Authenticated via Kerberos principal %s" % u["krb_principal"] + elif authtype == koji.AUTHTYPE_SSL: + print "Authenticated via client certificate %s" % options.cert def handle_runroot(options, session, args): "[admin] Run a command in a buildroot" diff --git a/hub/kojihub.py b/hub/kojihub.py index c3cdd3d..07461b8 100644 --- a/hub/kojihub.py +++ b/hub/kojihub.py @@ -9929,10 +9929,12 @@ class RootExports(object): def getLoggedInUser(self): """Return information about the currently logged-in user. Returns data - in the same format as getUser(). If there is no currently logged-in user, - return None.""" + in the same format as getUser(), plus the authtype. If there is no + currently logged-in user, return None.""" if context.session.logged_in: - return self.getUser(context.session.user_id) + me = self.getUser(context.session.user_id) + me['authtype'] = context.session.authtype + return me else: return None diff --git a/koji/auth.py b/koji/auth.py index d419d77..710f347 100644 --- a/koji/auth.py +++ b/koji/auth.py @@ -57,6 +57,7 @@ class Session(object): self.master = None self.key = None self.user_id = None + self.authtype = None self.hostip = None self.user_data = {} self.message = ''