From 66050b3338a96298445a18b1650e076d98c55714 Mon Sep 17 00:00:00 2001 From: Christopher Bartz Date: Wed, 17 Dec 2014 12:46:53 +0100 Subject: [PATCH] Password prompt if key is not specified. --- bin/swauth-add-account | 3 +++ bin/swauth-add-user | 3 +++ bin/swauth-cleanup-tokens | 3 +++ bin/swauth-delete-account | 3 +++ bin/swauth-delete-user | 3 +++ bin/swauth-list | 3 +++ bin/swauth-prep | 3 +++ bin/swauth-set-account-service | 3 +++ 8 files changed, 24 insertions(+) diff --git a/bin/swauth-add-account b/bin/swauth-add-account index 88f8010..cda3eef 100755 --- a/bin/swauth-add-account +++ b/bin/swauth-add-account @@ -14,6 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +from getpass import getpass import gettext from optparse import OptionParser from os.path import basename @@ -46,6 +47,8 @@ if __name__ == '__main__': (options, args) = parser.parse_args(args) if len(args) != 1: parser.parse_args(['-h']) + if not options.admin_key: + options.admin_key = getpass() account = args[0] parsed = urlparse(options.admin_url) if parsed.scheme not in ('http', 'https'): diff --git a/bin/swauth-add-user b/bin/swauth-add-user index 82bf073..1d9193f 100755 --- a/bin/swauth-add-user +++ b/bin/swauth-add-user @@ -14,6 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +from getpass import getpass import gettext from optparse import OptionParser from os.path import basename @@ -56,6 +57,8 @@ if __name__ == '__main__': (options, args) = parser.parse_args(args) if len(args) != 3: parser.parse_args(['-h']) + if not options.admin_key: + options.admin_key = getpass() account, user, password = args parsed = urlparse(options.admin_url) if parsed.scheme not in ('http', 'https'): diff --git a/bin/swauth-cleanup-tokens b/bin/swauth-cleanup-tokens index 54bed9d..1588635 100755 --- a/bin/swauth-cleanup-tokens +++ b/bin/swauth-cleanup-tokens @@ -18,6 +18,7 @@ try: import simplejson as json except ImportError: import json +from getpass import getpass import gettext import re from datetime import datetime, timedelta @@ -56,6 +57,8 @@ if __name__ == '__main__': (options, args) = parser.parse_args(args) if len(args) != 0: parser.parse_args(['-h']) + if not options.admin_key: + options.admin_key = getpass() options.admin_url = options.admin_url.rstrip('/') if not options.admin_url.endswith('/v1.0'): options.admin_url += '/v1.0' diff --git a/bin/swauth-delete-account b/bin/swauth-delete-account index 224e3b3..fe41a3d 100755 --- a/bin/swauth-delete-account +++ b/bin/swauth-delete-account @@ -14,6 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +from getpass import getpass import gettext from optparse import OptionParser from os.path import basename @@ -40,6 +41,8 @@ if __name__ == '__main__': (options, args) = parser.parse_args(args) if len(args) != 1: parser.parse_args(['-h']) + if not options.admin_key: + options.admin_key = getpass() account = args[0] parsed = urlparse(options.admin_url) if parsed.scheme not in ('http', 'https'): diff --git a/bin/swauth-delete-user b/bin/swauth-delete-user index 3991d9a..713a48d 100755 --- a/bin/swauth-delete-user +++ b/bin/swauth-delete-user @@ -14,6 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +from getpass import getpass import gettext from optparse import OptionParser from os.path import basename @@ -40,6 +41,8 @@ if __name__ == '__main__': (options, args) = parser.parse_args(args) if len(args) != 2: parser.parse_args(['-h']) + if not options.admin_key: + options.admin_key = getpass() account, user = args parsed = urlparse(options.admin_url) if parsed.scheme not in ('http', 'https'): diff --git a/bin/swauth-list b/bin/swauth-list index c49af04..0c9ed37 100755 --- a/bin/swauth-list +++ b/bin/swauth-list @@ -18,6 +18,7 @@ try: import simplejson as json except ImportError: import json +from getpass import getpass import gettext from optparse import OptionParser from os.path import basename @@ -60,6 +61,8 @@ If the [user] is '.groups', the active groups for the account will be listed. (options, args) = parser.parse_args(args) if len(args) > 2: parser.parse_args(['-h']) + if not options.admin_key: + options.admin_key = getpass() parsed = urlparse(options.admin_url) if parsed.scheme not in ('http', 'https'): raise Exception('Cannot handle protocol scheme %s for url %s' % diff --git a/bin/swauth-prep b/bin/swauth-prep index bf2384f..cd790a5 100755 --- a/bin/swauth-prep +++ b/bin/swauth-prep @@ -14,6 +14,7 @@ # See the License for the specific language governing permissions and # limitations under the License. +from getpass import getpass import gettext from optparse import OptionParser from os.path import basename @@ -40,6 +41,8 @@ if __name__ == '__main__': (options, args) = parser.parse_args(args) if args: parser.parse_args(['-h']) + if not options.admin_key: + options.admin_key = getpass() parsed = urlparse(options.admin_url) if parsed.scheme not in ('http', 'https'): raise Exception('Cannot handle protocol scheme %s for url %s' % diff --git a/bin/swauth-set-account-service b/bin/swauth-set-account-service index b0bed38..710b0eb 100755 --- a/bin/swauth-set-account-service +++ b/bin/swauth-set-account-service @@ -18,6 +18,7 @@ try: import simplejson as json except ImportError: import json +from getpass import getpass import gettext from optparse import OptionParser from os.path import basename @@ -50,6 +51,8 @@ Example: %prog -K swauthkey test storage local http://127.0.0.1:8080/v1/AUTH_018 (options, args) = parser.parse_args(args) if len(args) != 4: parser.parse_args(['-h']) + if not options.admin_key: + options.admin_key = getpass() account, service, name, url = args parsed = urlparse(options.admin_url) if parsed.scheme not in ('http', 'https'):