Skip to content

Commit cefe715

Browse files
author
Dean Troyer
committed
Fix token/endpoint auth plugin
[This is not quite reduced from the original proposed fix as some changes have merged that complicate the switch to OSC_Config and v2 auth broke anyway.] Fix the --os-token --os-url breakage in the switch to ksa. Closes-bug: 1593664 Change-Id: I3ac23234fbf647fb145c7bd151d53c5c105462bf
1 parent a60f16b commit cefe715

1 file changed

Lines changed: 30 additions & 25 deletions

File tree

openstackclient/api/auth_plugin.py

Lines changed: 30 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -15,50 +15,55 @@
1515

1616
import logging
1717

18-
from oslo_config import cfg
19-
from six.moves.urllib import parse as urlparse
20-
21-
from keystoneauth1.loading._plugins import admin_token as token_endpoint
18+
from keystoneauth1 import loading
2219
from keystoneauth1.loading._plugins.identity import generic as ksa_password
20+
from keystoneauth1 import token_endpoint
21+
from six.moves.urllib import parse as urlparse
2322

2423
from openstackclient.i18n import _
2524

2625
LOG = logging.getLogger(__name__)
2726

2827

29-
class TokenEndpoint(token_endpoint.AdminToken):
28+
class TokenEndpoint(loading.BaseLoader):
3029
"""Auth plugin to handle traditional token/endpoint usage
3130
32-
Implements the methods required to handle token authentication
33-
with a user-specified token and service endpoint; no Identity calls
34-
are made for re-scoping, service catalog lookups or the like.
35-
36-
The purpose of this plugin is to get rid of the special-case paths
37-
in the code to handle this authentication format. Its primary use
38-
is for bootstrapping the Keystone database.
31+
Keystoneauth contains a Token plugin class that now correctly
32+
handles the token/endpoint auth compatible with OSC. However,
33+
the AdminToken loader deprecates the 'url' argument, which breaks
34+
OSC compatibility, so make one that works.
3935
"""
4036

37+
@property
38+
def plugin_class(self):
39+
return token_endpoint.Token
40+
4141
def load_from_options(self, url, token, **kwargs):
4242
"""A plugin for static authentication with an existing token
4343
4444
:param string url: Service endpoint
4545
:param string token: Existing token
4646
"""
47-
return super(TokenEndpoint, self).load_from_options(endpoint=url,
48-
token=token)
4947

50-
def get_options(self):
51-
options = super(TokenEndpoint, self).get_options()
52-
53-
options.extend([
54-
# Maintain name 'url' for compatibility
55-
cfg.StrOpt('url',
56-
help=_('Specific service endpoint to use')),
57-
cfg.StrOpt('token',
58-
secret=True,
59-
help=_('Authentication token to use')),
60-
])
48+
return super(TokenEndpoint, self).load_from_options(
49+
endpoint=url,
50+
token=token,
51+
)
6152

53+
def get_options(self):
54+
"""Return the legacy options"""
55+
56+
options = [
57+
loading.Opt(
58+
'url',
59+
help=_('Specific service endpoint to use'),
60+
),
61+
loading.Opt(
62+
'token',
63+
secret=True,
64+
help=_('Authentication token to use'),
65+
),
66+
]
6267
return options
6368

6469

0 commit comments

Comments
 (0)