| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
from oslo_config import cfg |
| 14 |
|
| 15 |
from keystoneclient.auth.identity.v3 import base |
| 16 |
|
| 17 |
|
| 18 |
__all__ = ('TokenMethod', 'Token') |
| 19 |
|
| 20 |
|
| 21 |
class TokenMethod(base.AuthMethod): |
| 22 |
"""Construct an Auth plugin to fetch a token from a token. |
| 23 |
|
| 24 |
:param string token: Token for authentication. |
| 25 |
""" |
| 26 |
|
| 27 |
_method_parameters = ['token'] |
| 28 |
|
| 29 |
def get_auth_data(self, session, auth, headers, **kwargs): |
| 30 |
headers['X-Auth-Token'] = self.token |
| 31 |
return 'token', {'id': self.token} |
| 32 |
|
| 33 |
|
| 34 |
class Token(base.AuthConstructor): |
| 35 |
"""A plugin for authenticating with an existing Token. |
| 36 |
|
| 37 |
:param string auth_url: Identity service endpoint for authentication. |
| 38 |
:param string token: Token for authentication. |
| 39 |
:param string trust_id: Trust ID for trust scoping. |
| 40 |
:param string domain_id: Domain ID for domain scoping. |
| 41 |
:param string domain_name: Domain name for domain scoping. |
| 42 |
:param string project_id: Project ID for project scoping. |
| 43 |
:param string project_name: Project name for project scoping. |
| 44 |
:param string project_domain_id: Project's domain ID for project. |
| 45 |
:param string project_domain_name: Project's domain name for project. |
| 46 |
:param bool reauthenticate: Allow fetching a new token if the current one |
| 47 |
is going to expire. (optional) default True |
| 48 |
""" |
| 49 |
|
| 50 |
_auth_method_class = TokenMethod |
| 51 |
|
| 52 |
def __init__(self, auth_url, token, **kwargs): |
| 53 |
super(Token, self).__init__(auth_url, token=token, **kwargs) |
| 54 |
|
| 55 |
@classmethod |
| 56 |
def get_options(cls): |
| 57 |
options = super(Token, cls).get_options() |
| 58 |
|
| 59 |
options.extend([ |
| 60 |
cfg.StrOpt('token', |
| 61 |
secret=True, |
| 62 |
help='Token to authenticate with'), |
| 63 |
]) |
| 64 |
|
| 65 |
return options |