Sha256: 5de4693b67875e674e09a4b0ecc64c3012620e96d9fd3fb11d867aa7eca98efe
Contents?: true
Size: 1.43 KB
Versions: 21
Compression:
Stored size: 1.43 KB
Contents
module Fog module Brightbox class Storage class AuthenticationRequest attr_accessor :access_token, :management_url attr_accessor :user, :tenant def initialize(config) @config = config end def authenticate response = authentication_request self.access_token = response.headers["X-Auth-Token"] self.management_url = response.headers["X-Server-Management-Url"] || response.headers["X-Storage-Url"] self rescue Excon::Errors::Unauthorized => error raise Fog::Brightbox::Storage::AuthenticationRequired.slurp(error) end private def authentication_request authentication_url = URI.parse(@config.storage_url.to_s) connection = Fog::Core::Connection.new(authentication_url.to_s) request_settings = { :expects => [200, 204], :headers => auth_headers, :method => "GET", :path => "v1" } connection.request(request_settings) end def auth_headers if @config.user_credentials? { "X-Auth-User" => @config.username, "X-Auth-Key" => @config.password } else { "X-Auth-User" => @config.client_id, "X-Auth-Key" => @config.client_secret } end end end end end end
Version data entries
21 entries across 21 versions & 1 rubygems