1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-01-26 10:03:37 +03:00

feature #985: Add path support for EC2 signature

This commit is contained in:
Daniel Molina 2012-01-19 12:36:41 +01:00
parent 75470c6659
commit be3d1fedf9
3 changed files with 20 additions and 5 deletions

View File

@ -44,6 +44,7 @@ module EC2CloudAuth
params.delete('Signature')
params.delete('econe_host')
params.delete('econe_port')
params.delete('econe_path')
req_desc = params.sort {|x,y| x[0].downcase <=> y[0].downcase}.to_s
digest_generator = OpenSSL::Digest::Digest.new(digest)
@ -59,6 +60,7 @@ module EC2CloudAuth
server_host = params.delete('econe_host')
server_port = params.delete('econe_port')
server_path = params.delete('econe_path') || '/'
if include_port
server_str = "#{server_host}:#{server_port}"
else
@ -68,7 +70,8 @@ module EC2CloudAuth
canonical_str = AWS.canonical_string(
params,
server_str,
env['REQUEST_METHOD'])
env['REQUEST_METHOD'],
server_path)
# Use the correct signature strength
sha_strength = case params['SignatureMethod']

View File

@ -76,7 +76,8 @@ module EC2QueryClient
:secret_access_key => @access_key_secret,
:server => @uri.host,
:port => @uri.port,
:use_ssl => @uri.scheme == 'https')
:use_ssl => @uri.scheme == 'https',
:path => @uri.path)
end

View File

@ -44,6 +44,7 @@ $: << RUBY_LIB_LOCATION+"/cloud/econe"
require 'rubygems'
require 'sinatra'
require 'yaml'
require 'uri'
require 'EC2QueryServer'
require 'CloudAuth'
@ -89,12 +90,21 @@ end
set :cloud_auth, cloud_auth
econe_host = conf[:ssl_server]
econe_host ||= conf[:server]
econe_port = conf[:port]
if conf
if conf[:ssl_server]
uri = URI.parse(conf[:ssl_server])
econe_host = uri.host
econe_port = uri.port
econe_path = uri.path
else
econe_host = conf[:server]
econe_port = conf[:port]
econe_path = '/'
end
set :econe_host, econe_host
set :econe_port, econe_port
set :econe_path, econe_path
##############################################################################
# Actions
@ -104,6 +114,7 @@ before do
begin
params['econe_host'] = settings.econe_host
params['econe_port'] = settings.econe_port
params['econe_path'] = settings.econe_path
username = settings.cloud_auth.auth(request.env, params)
rescue Exception => e
error 500, error_xml("AuthFailure", 0)