diff options
author | Tim Burke <tim.burke@gmail.com> | 2023-03-10 21:39:57 -0800 |
---|---|---|
committer | Tim Burke <tim.burke@gmail.com> | 2023-03-23 20:32:23 -0700 |
commit | ee952c1bf250550d5da5b8a988e9e930edefce86 (patch) | |
tree | 71160f3d6d940ac1bb72a3e6185aae3731a0d243 /swiftclient | |
parent | 825145e9e6259d4a8d25502b2a6cc1257d9e86ba (diff) | |
download | python-swiftclient-ee952c1bf250550d5da5b8a988e9e930edefce86.tar.gz |
Ensure v*password auth_type correctly implies auth version
Change-Id: I787b0988b7518850f1e1f93ca269f39f8cdec15c
Diffstat (limited to 'swiftclient')
-rw-r--r-- | swiftclient/service.py | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/swiftclient/service.py b/swiftclient/service.py index 79cf86c..3d1b476 100644 --- a/swiftclient/service.py +++ b/swiftclient/service.py @@ -90,14 +90,26 @@ class SwiftError(Exception): def process_options(options): + auth_types_to_versions = { + 'v1password': '1.0', + 'v2password': '2.0', + 'v3password': '3', + 'v3applicationcredential': '3', + } + + version_from_type = auth_types_to_versions.get(options['os_auth_type']) + if version_from_type: + options['auth_version'] = version_from_type + # tolerate sloppy auth_version if options.get('auth_version') == '3.0': options['auth_version'] = '3' elif options.get('auth_version') == '2': options['auth_version'] = '2.0' - if options.get('auth_version') not in ('2.0', '3') and not all( - options.get(key) for key in ('auth', 'user', 'key')): + if options.get('auth_version') not in ('2.0', '3') and \ + options.get('os_auth_type') != 'v1password' and \ + not all(options.get(key) for key in ('auth', 'user', 'key')): # Use keystone auth if any of the new-style args are present if any(options.get(k) for k in ( 'os_user_domain_id', @@ -109,9 +121,6 @@ def process_options(options): else: options['auth_version'] = '2.0' - if options.get('os_auth_type', None) == 'v3applicationcredential': - options['auth_version'] == '3' - # Use new-style args if old ones not present if not options['auth'] and options['os_auth_url']: options['auth'] = options['os_auth_url'] |