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

[AWS] make beanstalk, cdn, cloudformation, cloudwatch, elasticache, elb, storage, rds, ses, sns, route53 temporary credential friendly

This commit is contained in:
Frederick Cheung 2012-06-20 23:16:34 +01:00
parent 4bee496f8c
commit a715819976
12 changed files with 16 additions and 3 deletions

View file

@ -111,6 +111,7 @@ module Fog
params,
{
:aws_access_key_id => @aws_access_key_id,
:aws_session_token => @aws_session_token,
:hmac => @hmac,
:host => @host,
:path => @path,

View file

@ -119,6 +119,7 @@ module Fog
params[:headers] ||= {}
params[:headers]['Date'] = Fog::Time.now.to_date_header
params[:headers]['x-amz-security-token'] = @aws_session_token if @aws_session_token
params[:headers]['Authorization'] = "AWS #{@aws_access_key_id}:#{signature(params)}"
params[:path] = "/#{@version}/#{params[:path]}"
@connection.request(params, &block)

View file

@ -86,6 +86,7 @@ module Fog
params,
{
:aws_access_key_id => @aws_access_key_id,
:aws_session_token => @aws_session_token,
:hmac => @hmac,
:host => @host,
:path => @path,

View file

@ -99,6 +99,7 @@ module Fog
params,
{
:aws_access_key_id => @aws_access_key_id,
:aws_session_token => @aws_session_token,
:hmac => @hmac,
:host => @host,
:path => @path,

View file

@ -122,6 +122,7 @@ module Fog
refresh_credentials_if_expired
params[:headers] ||= {}
params[:headers]['Date'] = Fog::Time.now.to_date_header
params[:headers]['x-amz-security-token'] = @aws_session_token if @aws_session_token
params[:headers]['X-Amzn-Authorization'] = "AWS3-HTTPS AWSAccessKeyId=#{@aws_access_key_id},Algorithm=HmacSHA1,Signature=#{signature(params)}"
params[:path] = "/#{@version}/#{params[:path]}"
@connection.request(params, &block)

View file

@ -88,6 +88,7 @@ module Fog
params,
{
:aws_access_key_id => @aws_access_key_id,
:aws_session_token => @aws_session_token,
:hmac => @hmac,
:host => @host,
:path => @path,

View file

@ -160,6 +160,7 @@ module Fog
params,
{
:aws_access_key_id => @aws_access_key_id,
:aws_session_token => @aws_session_token,
:hmac => @hmac,
:host => @host,
:path => @path,

View file

@ -102,6 +102,7 @@ module Fog
params,
{
:aws_access_key_id => @aws_access_key_id,
:aws_session_token => @aws_session_token,
:hmac => @hmac,
:host => @host,
:path => @path,

View file

@ -169,6 +169,7 @@ module Fog
params,
{
:aws_access_key_id => @aws_access_key_id,
:aws_session_token => @aws_session_token,
:hmac => @hmac,
:host => @host,
:path => @path,

View file

@ -82,11 +82,12 @@ module Fog
idempotent = params.delete(:idempotent)
parser = params.delete(:parser)
headers = {
'Content-Type' => 'application/x-www-form-urlencoded',
'Date' => Fog::Time.now.to_date_header
'Date' => Fog::Time.now.to_date_header,
}
headers['x-amz-security-token'] = @aws_session_token if @aws_session_token
#AWS3-HTTPS AWSAccessKeyId=<Your AWS Access Key ID>, Algorithm=HmacSHA256, Signature=<Signature>
headers['X-Amzn-Authorization'] = 'AWS3-HTTPS '
headers['X-Amzn-Authorization'] << 'AWSAccessKeyId=' << @aws_access_key_id

View file

@ -90,6 +90,7 @@ module Fog
params,
{
:aws_access_key_id => @aws_access_key_id,
:aws_session_token => @aws_session_token,
:hmac => @hmac,
:host => @host,
:path => @path,

View file

@ -99,6 +99,7 @@ module Fog
params[:headers]['Date'] = expires.to_i
params[:path] = Fog::AWS.escape(params[:path]).gsub('%2F', '/')
query = []
params[:headers]['x-amz-security-token'] = @aws_session_token if @aws_session_token
if params[:query]
for key, value in params[:query]
query << "#{key}=#{Fog::AWS.escape(value)}"
@ -107,6 +108,7 @@ module Fog
query << "AWSAccessKeyId=#{@aws_access_key_id}"
query << "Signature=#{Fog::AWS.escape(signature(params))}"
query << "Expires=#{params[:headers]['Date']}"
query << "x-amz-security-token=#{Fog::AWS.escape(@aws_session_token)}" if @aws_session_token
port_part = params[:port] && ":#{params[:port]}"
"#{params[:scheme]}://#{params[:host]}#{port_part}/#{params[:path]}?#{query.join('&')}"
end
@ -379,8 +381,8 @@ DATA
refresh_credentials_if_expired
params[:headers]['Date'] = Fog::Time.now.to_date_header
params[:headers]['x-amz-security-token'] = @aws_session_token if @aws_session_token
params[:headers]['Authorization'] = "AWS #{@aws_access_key_id}:#{signature(params)}"
# FIXME: ToHashParser should make this not needed
original_params = params.dup