This is an automated email from the ASF dual-hosted git repository.
chetanm pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-openwhisk.git
The following commit(s) were added to refs/heads/master by this push:
new 8f18797 Add revoke key feature. (#4249)
8f18797 is described below
commit 8f18797b7e3e2872c4a3e406e07424995a80b980
Author: rodric rabbah <[email protected]>
AuthorDate: Tue Feb 12 04:54:09 2019 -0500
Add revoke key feature. (#4249)
Adds support for 3 new flags
-r, --revoke revoke existing key and create a new one
-g, --genonly generate a uuid and key but do not store them in the
database
-s, --silent do not should the new key on the console
---
tools/admin/wskadmin | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)
diff --git a/tools/admin/wskadmin b/tools/admin/wskadmin
index d6e1cff..82a208d 100755
--- a/tools/admin/wskadmin
+++ b/tools/admin/wskadmin
@@ -106,6 +106,9 @@ def parseArgs():
subcmd.add_argument('subject', help='the subject to create')
subcmd.add_argument('-u', '--auth', help='the uuid:key to initialize the
subject authorization key with')
subcmd.add_argument('-ns', '--namespace', help='create key for given
namespace instead (defaults to subject id')
+ subcmd.add_argument('-r', '--revoke', help='revoke existing key and create
a new one', action='store_true')
+ subcmd.add_argument('-g', '--genonly', help='generate a uuid and key but
do not store them in the database', action='store_true')
+ subcmd.add_argument('-s', '--silent', help='do not should the new key on
the console', action='store_true')
subcmd = subparser.add_parser('delete', help='delete a user')
subcmd.add_argument('subject', help='the subject to delete')
@@ -244,6 +247,10 @@ def createUserCmd(args, props):
uid = str(uuid.uuid4())
key = ''.join(random.choice(string.ascii_letters + string.digits) for
_ in range(64))
+ if args.genonly:
+ print('%s:%s' % (uid, key))
+ return 0
+
(doc, res) = getDocumentFromDb(props, args.subject, args.verbose)
if doc is None:
doc = {
@@ -266,6 +273,13 @@ def createUserCmd(args, props):
'uuid': uid,
'key': key
})
+ elif args.revoke:
+ if len(namespaces) == 1:
+ namespaces[0]['uuid'] = uid
+ namespaces[0]['key'] = key
+ else:
+ print('Namespace is not unique')
+ return 1
else:
print('Namespace already exists')
return 1
@@ -275,7 +289,8 @@ def createUserCmd(args, props):
res = insertIntoDatabase(props, doc, args.verbose)
if res.status in [201, 202]:
- print('%s:%s' % (uid, key))
+ if not args.silent:
+ print('%s:%s' % (uid, key))
else:
print('Failed to create subject (%s)' % res.read().strip())
return 1