1
0
Fork 0
mirror of https://github.com/fog/fog.git synced 2022-11-09 13:51:43 -05:00

[openstack] Make use of the unscoped token for reauthentication

This commit is contained in:
Philip Mark M. Deazeta 2012-11-15 10:04:53 +08:00 committed by Nelvin Driz
parent 27ba6d44a2
commit a9fb65985c
4 changed files with 10 additions and 5 deletions

View file

@ -84,6 +84,8 @@ module Fog
service = body['access']['serviceCatalog'].
detect {|s| service_name.include?(s['type']) }
options[:unscoped_token] = body['access']['token']['id']
unless service
unless tenant_name
response = Fog::Connection.new(
@ -133,7 +135,8 @@ module Fog
:server_management_url => management_url,
:token => body['access']['token']['id'],
:expires => body['access']['token']['expires'],
:current_user_id => body['access']['user']['id']
:current_user_id => body['access']['user']['id'],
:unscoped_token => options[:unscoped_token]
}
end
@ -141,7 +144,7 @@ module Fog
api_key = options[:openstack_api_key].to_s
username = options[:openstack_username].to_s
tenant_name = options[:openstack_tenant].to_s
auth_token = options[:openstack_auth_token]
auth_token = options[:openstack_auth_token] || options[:unscoped_token]
uri = options[:openstack_auth_uri]
connection = Fog::Connection.new(uri.to_s, false, connection_options)

View file

@ -153,6 +153,7 @@ module Fog
class Real
attr_reader :current_user
attr_reader :current_tenant
attr_reader :unscoped_token
def initialize(options={})
@openstack_auth_token = options[:openstack_auth_token]
@ -238,7 +239,7 @@ module Fog
private
def authenticate
if @openstack_must_reauthenticate || @openstack_auth_token.nil?
if !@openstack_management_url || @openstack_must_reauthenticate
options = {
:openstack_api_key => @openstack_api_key,
:openstack_username => @openstack_username,
@ -258,6 +259,7 @@ module Fog
@auth_token = credentials[:token]
@openstack_management_url = credentials[:server_management_url]
@openstack_current_user_id = credentials[:current_user_id]
@unscoped_token = credentials[:unscoped_token]
uri = URI.parse(@openstack_management_url)
else
@auth_token = @openstack_auth_token

View file

@ -172,7 +172,7 @@ module Fog
private
def authenticate
if @openstack_must_reauthenticate || @openstack_auth_token.nil?
if !@openstack_management_url || @openstack_must_reauthenticate
options = {
:openstack_tenant => @openstack_tenant,
:openstack_api_key => @openstack_api_key,

View file

@ -175,7 +175,7 @@ module Fog
private
def authenticate
if @openstack_must_reauthenticate || @openstack_auth_token.nil?
if !@openstack_management_url || @openstack_must_reauthenticate
options = {
:openstack_tenant => @openstack_tenant,
:openstack_api_key => @openstack_api_key,