Debian Codegraph @

keystoneclient/auth/identity/v3/token.py

raw symbols SCIP
1 # Licensed under the Apache License, Version 2.0 (the "License"); you may
2 # not use this file except in compliance with the License. You may obtain
3 # a copy of the License at
4 #
5 # http://www.apache.org/licenses/LICENSE-2.0
6 #
7 # Unless required by applicable law or agreed to in writing, software
8 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
9 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
10 # License for the specific language governing permissions and limitations
11 # under the License.
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