Class: Fog::OpenStack::Auth::Token::V3
Constant Summary
collapse
- DOMAIN_ID =
'default'.freeze
Instance Attribute Summary collapse
#catalog, #data, #expires, #tenant, #token, #user
Instance Method Summary
collapse
build, #get, #initialize
Instance Attribute Details
#domain ⇒ Object
Returns the value of attribute domain.
10
11
12
|
# File 'lib/fog/openstack/auth/token/v3.rb', line 10
def domain
@domain
end
|
#project ⇒ Object
Returns the value of attribute project.
10
11
12
|
# File 'lib/fog/openstack/auth/token/v3.rb', line 10
def project
@project
end
|
Instance Method Details
#build_credentials(auth) ⇒ Object
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
# File 'lib/fog/openstack/auth/token/v3.rb', line 69
def build_credentials(auth)
if auth[:openstack_project_id] || auth[:openstack_project_name]
@project = Fog::OpenStack::Auth::ProjectScope.new(
auth[:openstack_project_id],
auth[:openstack_project_name]
)
@project.domain = if auth[:openstack_project_domain_id] || auth[:openstack_project_domain_name]
Fog::OpenStack::Auth::Name.new(
auth[:openstack_project_domain_id],
auth[:openstack_project_domain_name]
)
elsif auth[:openstack_domain_id] || auth[:openstack_domain_name]
Fog::OpenStack::Auth::Name.new(
auth[:openstack_domain_id],
auth[:openstack_domain_name]
)
else
Fog::OpenStack::Auth::Name.new(DOMAIN_ID, nil)
end
elsif auth[:openstack_domain_id] || auth[:openstack_domain_name]
@domain = Fog::OpenStack::Auth::DomainScope.new(
auth[:openstack_domain_id],
auth[:openstack_domain_name]
)
end
if auth[:openstack_auth_token]
@token = auth[:openstack_auth_token]
else
@user = Fog::OpenStack::Auth::User.new(auth[:openstack_userid], auth[:openstack_username])
@user.password = auth[:openstack_api_key]
@user.domain = if auth[:openstack_user_domain_id] || auth[:openstack_user_domain_name]
Fog::OpenStack::Auth::Name.new(
auth[:openstack_user_domain_id],
auth[:openstack_user_domain_name]
)
elsif auth[:openstack_domain_id] || auth[:openstack_domain_name]
Fog::OpenStack::Auth::Name.new(
auth[:openstack_domain_id],
auth[:openstack_domain_name]
)
else
Fog::OpenStack::Auth::Name.new(DOMAIN_ID, nil)
end
end
credentials
end
|
#credentials ⇒ Object
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/fog/openstack/auth/token/v3.rb', line 15
def credentials
identity = if @token
{
'methods' => ['token'],
'token' => {'id' => @token}
}
else
{
'methods' => ['password'],
'password' => @user.identity
}
end
if scope
{
'auth' => {
'identity' => identity,
'scope' => scope
}
}
else
{'auth' => {'identity' => identity}}
end
end
|
#path ⇒ Object
48
49
50
|
# File 'lib/fog/openstack/auth/token/v3.rb', line 48
def path
'/auth/tokens'
end
|
#prefix_path(uri) ⇒ Object
40
41
42
43
44
45
46
|
# File 'lib/fog/openstack/auth/token/v3.rb', line 40
def prefix_path(uri)
if uri.path =~ /\/v3(\/)*.*$/
''
else
'/v3'
end
end
|
#scope ⇒ Object
52
53
54
55
|
# File 'lib/fog/openstack/auth/token/v3.rb', line 52
def scope
return @project.identity if @project
return @domain.identity if @domain
end
|
#set(response) ⇒ Object
57
58
59
60
61
62
63
64
65
66
67
|
# File 'lib/fog/openstack/auth/token/v3.rb', line 57
def set(response)
@data = Fog::JSON.decode(response.body)
@token = response.['x-subject-token']
@expires = @data['token']['expires_at']
@tenant = @data['token']['project']
@user = @data['token']['user']
catalog = @data['token']['catalog']
if catalog
@catalog = Fog::OpenStack::Auth::Catalog::V3.new(catalog)
end
end
|