summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2019-03-16 15:15:56 +0200
committerLars Wirzenius <liw@liw.fi>2019-03-16 15:15:56 +0200
commit100e9fa3565600f55df792f4c6c6efdb370bc3ab (patch)
tree19e2886d8f1aee2a66b6c3bb974529fce0853c41
parentfeddd854c095f9096f4a773c1738b1bc276ccce7 (diff)
downloadeffitool-100e9fa3565600f55df792f4c6c6efdb370bc3ab.tar.gz
Add: show-client subcommand
Also, list-clients now only shows the names.
-rw-r--r--README4
-rwxr-xr-xeffitool19
2 files changed, 19 insertions, 4 deletions
diff --git a/README b/README
index 9f28bed..de3bc4c 100644
--- a/README
+++ b/README
@@ -57,6 +57,10 @@ To list all known clients:
./effitool list-clients
+To show the allowed scopes for a specific client:
+
+ ./effitool show-client tomjon
+
Legalese
-----------------------------------------------------------------------------
diff --git a/effitool b/effitool
index f3897cd..52d5578 100755
--- a/effitool
+++ b/effitool
@@ -242,10 +242,18 @@ class Tool:
token = self.get_admin_token(server)
api = HTTPAPI(server['url'])
obj = api.get_list(token, '/clients')
- for name in obj.get('resources', []):
- client = api.get_json(token, '/clients/{}'.format(name))
- del client['hashed_secret']
- print(json.dumps(client, indent=4))
+ for name in sorted(obj.get('resources', [])):
+ print(name)
+
+ def show_clients(self, args):
+ server = self.get_chosen_server(args)
+ token = self.get_admin_token(server)
+ api = HTTPAPI(server['url'])
+ obj = api.get_list(token, '/clients')
+ client = api.get_json(token, '/clients/{}'.format(args['client-name']))
+ del client['hashed_secret']
+ for scope in client.get('allowed_scopes', []):
+ print(scope)
def process_args(config):
@@ -259,6 +267,9 @@ def process_args(config):
('--client-secret', {'required':True}),
]),
('list-clients', tool.list_clients, []),
+ ('show-client', tool.show_clients, [
+ ('client-name', {}),
+ ]),
]
p = argparse.ArgumentParser()