Module: SwiftStorage::Auth::V2_0
- Extended by:
- Forwardable
- Defined in:
- lib/swift_storage/auth/v2_0.rb
Instance Attribute Summary collapse
-
#auth_path ⇒ Object
Returns the value of attribute auth_path.
Instance Method Summary collapse
Instance Attribute Details
#auth_path ⇒ Object
Returns the value of attribute auth_path.
7 8 9 |
# File 'lib/swift_storage/auth/v2_0.rb', line 7 def auth_path @auth_path end |
Instance Method Details
#authenticate! ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/swift_storage/auth/v2_0.rb', line 9 def authenticate! res = request("#{auth_url}/tokens", method: :post, json_data: auth_data) JSON.parse(res.body).tap do |body| @auth_token = body['access']['token']['id'] @expires = body['access']['token']['expires'] storage_endpoint(body['access']['serviceCatalog']) do |endpoint| self.storage_url = endpoint['publicURL'] @storage_token = endpoint['id'] @auth_at = Time.now end end end |
#authenticated? ⇒ Boolean
23 24 25 |
# File 'lib/swift_storage/auth/v2_0.rb', line 23 def authenticated? !!(self.storage_url && auth_token && expires && Time.now.utc < Time.parse(expires).utc) end |