Class: Misty::AuthV3
- Inherits:
-
Auth
- Object
- Auth
- Misty::AuthV3
show all
- Defined in:
- lib/misty/auth/auth_v3.rb
Instance Attribute Summary
Attributes inherited from Auth
#catalog
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Auth
#authenticate, #expired?, factory, #get_endpoint, #get_token, #initialize
Constructor Details
This class inherits a constructor from Misty::Auth
Class Method Details
.path ⇒ Object
5
6
7
|
# File 'lib/misty/auth/auth_v3.rb', line 5
def self.path
"/v3/auth/tokens"
end
|
Instance Method Details
#catalog_endpoints(endpoints, region, interface) ⇒ Object
9
10
11
12
13
14
15
|
# File 'lib/misty/auth/auth_v3.rb', line 9
def catalog_endpoints(endpoints, region, interface)
endpoints.each do |endpoint|
if endpoint["region_id"] == region && endpoint["interface"] == interface
return endpoint["url"]
end
end
end
|
#credentials_valid?(creds) ⇒ Boolean
17
18
19
|
# File 'lib/misty/auth/auth_v3.rb', line 17
def credentials_valid?(creds)
true if creds[:user] && creds[:password] && creds[:project]
end
|
#get_endpoint_url(endpoints, region, interface) ⇒ Object
21
22
23
24
25
|
# File 'lib/misty/auth/auth_v3.rb', line 21
def get_endpoint_url(endpoints, region, interface)
endpoint = endpoints.select { |ep| ep["region_id"] == region && ep["interface"] == interface }
raise CatalogError, "No endpoint available for region '#{region}' and interface '#{interface}'" unless endpoint
endpoint[0]["url"]
end
|
#scoped_credentials(creds) ⇒ Object
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
# File 'lib/misty/auth/auth_v3.rb', line 34
def scoped_credentials(creds)
creds[:domain] ||= "default"
{
"auth": {
"identity": {
"methods": ["password"],
"password": {
"user": {
"name": creds[:user],
"domain": { "id": "default" },
"password": creds[:password]
}
}
},
"scope": {
"project": {
"name": creds[:project],
"domain": { "id": creds[:domain] }
}
}
}
}
end
|
#setup(response) ⇒ Object
27
28
29
30
31
32
|
# File 'lib/misty/auth/auth_v3.rb', line 27
def setup(response)
payload = JSON.load(response.body)
@token = response["x-subject-token"]
@catalog = payload["token"]["catalog"]
@expires = payload["token"]["expires_at"]
end
|