Class: Miasma::Contrib::OpenStackApiCore::Authenticate
- Inherits:
-
Object
- Object
- Miasma::Contrib::OpenStackApiCore::Authenticate
- Defined in:
- lib/miasma/contrib/open_stack.rb
Overview
Authentication helper class
Direct Known Subclasses
Defined Under Namespace
Instance Attribute Summary collapse
-
#credentials ⇒ Smash
readonly
Credentials in use.
-
#token ⇒ Smash
readonly
Token info.
Instance Method Summary collapse
-
#api_token ⇒ String
Current API token.
-
#authentication_request ⇒ Smash
Authentication request body.
-
#identity_and_load ⇒ self
Identify with authentication endpoint and load the service catalog.
-
#initialize(credentials) ⇒ self
constructor
Create new instance.
-
#service_catalog ⇒ Smash
Remote service catalog.
-
#user ⇒ String
Username.
Constructor Details
#initialize(credentials) ⇒ self
Create new instance
22 23 24 |
# File 'lib/miasma/contrib/open_stack.rb', line 22 def initialize(credentials) @credentials = credentials.to_smash end |
Instance Attribute Details
#credentials ⇒ Smash (readonly)
Returns credentials in use.
17 18 19 |
# File 'lib/miasma/contrib/open_stack.rb', line 17 def credentials @credentials end |
#token ⇒ Smash (readonly)
Returns token info.
15 16 17 |
# File 'lib/miasma/contrib/open_stack.rb', line 15 def token @token end |
Instance Method Details
#api_token ⇒ String
Returns current API token.
39 40 41 42 43 44 |
# File 'lib/miasma/contrib/open_stack.rb', line 39 def api_token if(token.nil? || Time.now > token[:expires]) identify_and_load end token[:id] end |
#authentication_request ⇒ Smash
Returns authentication request body.
55 56 57 |
# File 'lib/miasma/contrib/open_stack.rb', line 55 def authentication_request raise NotImplementedError end |
#identity_and_load ⇒ self
Identify with authentication endpoint and load the service catalog
50 51 52 |
# File 'lib/miasma/contrib/open_stack.rb', line 50 def identity_and_load raise NotImplementedError end |
#service_catalog ⇒ Smash
Returns remote service catalog.
33 34 35 36 |
# File 'lib/miasma/contrib/open_stack.rb', line 33 def service_catalog load! @service_catalog end |
#user ⇒ String
Returns username.
27 28 29 30 |
# File 'lib/miasma/contrib/open_stack.rb', line 27 def user load! @user end |