class Openstack::Client::Authenticator
It retrieves token from OpenStack API and caches it.
:reek: IrresponsibleModule
Attributes
cache[R]
password[R]
uri[R]
username[R]
Public Class Methods
new( username:, password:, uri: Rails.application.config.x.openstack.fetch(:authentication_url), cache: Rails.cache )
click to toggle source
# File lib/openstack/client/authenticator.rb, line 19 def initialize( username:, password:, uri: Rails.application.config.x.openstack.fetch(:authentication_url), cache: Rails.cache ) @username = username @password = password @uri = URI(uri) @cache = cache end
Public Instance Methods
authenticate()
click to toggle source
# File lib/openstack/client/authenticator.rb, line 31 def authenticate cache_response if token_expired? authentication_succeed? end
authenticate_request() { || ... }
click to toggle source
# File lib/openstack/client/authenticator.rb, line 36 def authenticate_request return unless block_given? authenticate yield.tap do |request| request.add_field('x-auth-token', token) end