|
15 | 15 |
|
16 | 16 | import logging |
17 | 17 |
|
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 |
22 | 19 | 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 |
23 | 22 |
|
24 | 23 | from openstackclient.i18n import _ |
25 | 24 |
|
26 | 25 | LOG = logging.getLogger(__name__) |
27 | 26 |
|
28 | 27 |
|
29 | | -class TokenEndpoint(token_endpoint.AdminToken): |
| 28 | +class TokenEndpoint(loading.BaseLoader): |
30 | 29 | """Auth plugin to handle traditional token/endpoint usage |
31 | 30 |
|
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. |
39 | 35 | """ |
40 | 36 |
|
| 37 | + @property |
| 38 | + def plugin_class(self): |
| 39 | + return token_endpoint.Token |
| 40 | + |
41 | 41 | def load_from_options(self, url, token, **kwargs): |
42 | 42 | """A plugin for static authentication with an existing token |
43 | 43 |
|
44 | 44 | :param string url: Service endpoint |
45 | 45 | :param string token: Existing token |
46 | 46 | """ |
47 | | - return super(TokenEndpoint, self).load_from_options(endpoint=url, |
48 | | - token=token) |
49 | 47 |
|
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 | + ) |
61 | 52 |
|
| 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 | + ] |
62 | 67 | return options |
63 | 68 |
|
64 | 69 |
|
|
0 commit comments