diff options
Diffstat (limited to 'bonafide')
-rw-r--r-- | bonafide/src/leap/bonafide/_http.py | 2 | ||||
-rwxr-xr-x | bonafide/src/leap/bonafide/bonafide_cli.py | 16 | ||||
-rw-r--r-- | bonafide/src/leap/bonafide/session.py | 1 |
3 files changed, 12 insertions, 7 deletions
diff --git a/bonafide/src/leap/bonafide/_http.py b/bonafide/src/leap/bonafide/_http.py index b92cf57..8f05b42 100644 --- a/bonafide/src/leap/bonafide/_http.py +++ b/bonafide/src/leap/bonafide/_http.py @@ -50,7 +50,7 @@ def httpRequest(agent, url, values={}, headers={}, method='POST', token=None): headers['Authorization'] = ['Token token="%s"' % (bytes(token))] def handle_response(response): - print "RESPONSE CODE", response.code + # print "RESPONSE CODE", response.code if response.code == 204: d = defer.succeed('') else: diff --git a/bonafide/src/leap/bonafide/bonafide_cli.py b/bonafide/src/leap/bonafide/bonafide_cli.py index 30cae6a..3f500e4 100755 --- a/bonafide/src/leap/bonafide/bonafide_cli.py +++ b/bonafide/src/leap/bonafide/bonafide_cli.py @@ -63,7 +63,7 @@ def _display_registered(result, _session, _provider): '%s@%s' % (user, _provider)) -def run_command(command, _provider, username, password): +def run_command(command, _provider, username, password, skip_logout): api = provider.Api('https://api.%s:4430' % _provider) credentials = UsernamePassword(username, password) cdev_pem = os.path.expanduser( @@ -81,23 +81,29 @@ def run_command(command, _provider, username, password): sys.exit() d.addErrback(_authEb) - d.addCallback(lambda _: _session.logout()) + if not skip_logout: + d.addCallback(lambda _: _session.logout()) d.addBoth(_cbShutDown) reactor.run() + def main(): color_init() description = (Fore.YELLOW + 'Manage and configure a LEAP Account ' - 'using the bonafide protocol.' + Fore.RESET) + 'using the bonafide protocol.' + Fore.RESET) parser = argparse.ArgumentParser(description=description) parser.add_argument('command', type=str, choices=COMMANDS) + parser.add_argument( + '--skip-logout', action="store_true", + help=("Skip logout. Use this if you want to re-use the token.")) parser.add_argument('--provider', dest='provider', required=True) parser.add_argument('--username', dest='username', required=True) ns = parser.parse_args() password = getpass( - Fore.BLUE + '%s@%s password:' % (ns.username, ns.provider) + Fore.RESET) - run_command(ns.command, ns.provider, ns.username, password) + Fore.BLUE + '%s@%s password:' % ( + ns.username, ns.provider) + Fore.RESET) + run_command(ns.command, ns.provider, ns.username, password, ns.skip_logout) if __name__ == '__main__': diff --git a/bonafide/src/leap/bonafide/session.py b/bonafide/src/leap/bonafide/session.py index 4fa3299..8343a91 100644 --- a/bonafide/src/leap/bonafide/session.py +++ b/bonafide/src/leap/bonafide/session.py @@ -107,7 +107,6 @@ class Session(object): uri = self._api.get_logout_uri() met = self._api.get_logout_method() auth = yield self._request(self._agent, uri, method=met) - print "AUTH RESULT->", auth self.username = None self.password = None self._initialize_session() |