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:
parent
4bee496f8c
commit
a715819976
12 changed files with 16 additions and 3 deletions
|
@ -111,6 +111,7 @@ module Fog
|
||||||
params,
|
params,
|
||||||
{
|
{
|
||||||
:aws_access_key_id => @aws_access_key_id,
|
:aws_access_key_id => @aws_access_key_id,
|
||||||
|
:aws_session_token => @aws_session_token,
|
||||||
:hmac => @hmac,
|
:hmac => @hmac,
|
||||||
:host => @host,
|
:host => @host,
|
||||||
:path => @path,
|
:path => @path,
|
||||||
|
|
|
@ -119,6 +119,7 @@ module Fog
|
||||||
|
|
||||||
params[:headers] ||= {}
|
params[:headers] ||= {}
|
||||||
params[:headers]['Date'] = Fog::Time.now.to_date_header
|
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[:headers]['Authorization'] = "AWS #{@aws_access_key_id}:#{signature(params)}"
|
||||||
params[:path] = "/#{@version}/#{params[:path]}"
|
params[:path] = "/#{@version}/#{params[:path]}"
|
||||||
@connection.request(params, &block)
|
@connection.request(params, &block)
|
||||||
|
|
|
@ -86,6 +86,7 @@ module Fog
|
||||||
params,
|
params,
|
||||||
{
|
{
|
||||||
:aws_access_key_id => @aws_access_key_id,
|
:aws_access_key_id => @aws_access_key_id,
|
||||||
|
:aws_session_token => @aws_session_token,
|
||||||
:hmac => @hmac,
|
:hmac => @hmac,
|
||||||
:host => @host,
|
:host => @host,
|
||||||
:path => @path,
|
:path => @path,
|
||||||
|
|
|
@ -99,6 +99,7 @@ module Fog
|
||||||
params,
|
params,
|
||||||
{
|
{
|
||||||
:aws_access_key_id => @aws_access_key_id,
|
:aws_access_key_id => @aws_access_key_id,
|
||||||
|
:aws_session_token => @aws_session_token,
|
||||||
:hmac => @hmac,
|
:hmac => @hmac,
|
||||||
:host => @host,
|
:host => @host,
|
||||||
:path => @path,
|
:path => @path,
|
||||||
|
|
|
@ -122,6 +122,7 @@ module Fog
|
||||||
refresh_credentials_if_expired
|
refresh_credentials_if_expired
|
||||||
params[:headers] ||= {}
|
params[:headers] ||= {}
|
||||||
params[:headers]['Date'] = Fog::Time.now.to_date_header
|
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[:headers]['X-Amzn-Authorization'] = "AWS3-HTTPS AWSAccessKeyId=#{@aws_access_key_id},Algorithm=HmacSHA1,Signature=#{signature(params)}"
|
||||||
params[:path] = "/#{@version}/#{params[:path]}"
|
params[:path] = "/#{@version}/#{params[:path]}"
|
||||||
@connection.request(params, &block)
|
@connection.request(params, &block)
|
||||||
|
|
|
@ -88,6 +88,7 @@ module Fog
|
||||||
params,
|
params,
|
||||||
{
|
{
|
||||||
:aws_access_key_id => @aws_access_key_id,
|
:aws_access_key_id => @aws_access_key_id,
|
||||||
|
:aws_session_token => @aws_session_token,
|
||||||
:hmac => @hmac,
|
:hmac => @hmac,
|
||||||
:host => @host,
|
:host => @host,
|
||||||
:path => @path,
|
:path => @path,
|
||||||
|
|
|
@ -160,6 +160,7 @@ module Fog
|
||||||
params,
|
params,
|
||||||
{
|
{
|
||||||
:aws_access_key_id => @aws_access_key_id,
|
:aws_access_key_id => @aws_access_key_id,
|
||||||
|
:aws_session_token => @aws_session_token,
|
||||||
:hmac => @hmac,
|
:hmac => @hmac,
|
||||||
:host => @host,
|
:host => @host,
|
||||||
:path => @path,
|
:path => @path,
|
||||||
|
|
|
@ -102,6 +102,7 @@ module Fog
|
||||||
params,
|
params,
|
||||||
{
|
{
|
||||||
:aws_access_key_id => @aws_access_key_id,
|
:aws_access_key_id => @aws_access_key_id,
|
||||||
|
:aws_session_token => @aws_session_token,
|
||||||
:hmac => @hmac,
|
:hmac => @hmac,
|
||||||
:host => @host,
|
:host => @host,
|
||||||
:path => @path,
|
:path => @path,
|
||||||
|
|
|
@ -169,6 +169,7 @@ module Fog
|
||||||
params,
|
params,
|
||||||
{
|
{
|
||||||
:aws_access_key_id => @aws_access_key_id,
|
:aws_access_key_id => @aws_access_key_id,
|
||||||
|
:aws_session_token => @aws_session_token,
|
||||||
:hmac => @hmac,
|
:hmac => @hmac,
|
||||||
:host => @host,
|
:host => @host,
|
||||||
:path => @path,
|
:path => @path,
|
||||||
|
|
|
@ -82,11 +82,12 @@ module Fog
|
||||||
idempotent = params.delete(:idempotent)
|
idempotent = params.delete(:idempotent)
|
||||||
parser = params.delete(:parser)
|
parser = params.delete(:parser)
|
||||||
|
|
||||||
|
|
||||||
headers = {
|
headers = {
|
||||||
'Content-Type' => 'application/x-www-form-urlencoded',
|
'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>
|
#AWS3-HTTPS AWSAccessKeyId=<Your AWS Access Key ID>, Algorithm=HmacSHA256, Signature=<Signature>
|
||||||
headers['X-Amzn-Authorization'] = 'AWS3-HTTPS '
|
headers['X-Amzn-Authorization'] = 'AWS3-HTTPS '
|
||||||
headers['X-Amzn-Authorization'] << 'AWSAccessKeyId=' << @aws_access_key_id
|
headers['X-Amzn-Authorization'] << 'AWSAccessKeyId=' << @aws_access_key_id
|
||||||
|
|
|
@ -90,6 +90,7 @@ module Fog
|
||||||
params,
|
params,
|
||||||
{
|
{
|
||||||
:aws_access_key_id => @aws_access_key_id,
|
:aws_access_key_id => @aws_access_key_id,
|
||||||
|
:aws_session_token => @aws_session_token,
|
||||||
:hmac => @hmac,
|
:hmac => @hmac,
|
||||||
:host => @host,
|
:host => @host,
|
||||||
:path => @path,
|
:path => @path,
|
||||||
|
|
|
@ -99,6 +99,7 @@ module Fog
|
||||||
params[:headers]['Date'] = expires.to_i
|
params[:headers]['Date'] = expires.to_i
|
||||||
params[:path] = Fog::AWS.escape(params[:path]).gsub('%2F', '/')
|
params[:path] = Fog::AWS.escape(params[:path]).gsub('%2F', '/')
|
||||||
query = []
|
query = []
|
||||||
|
params[:headers]['x-amz-security-token'] = @aws_session_token if @aws_session_token
|
||||||
if params[:query]
|
if params[:query]
|
||||||
for key, value in params[:query]
|
for key, value in params[:query]
|
||||||
query << "#{key}=#{Fog::AWS.escape(value)}"
|
query << "#{key}=#{Fog::AWS.escape(value)}"
|
||||||
|
@ -107,6 +108,7 @@ module Fog
|
||||||
query << "AWSAccessKeyId=#{@aws_access_key_id}"
|
query << "AWSAccessKeyId=#{@aws_access_key_id}"
|
||||||
query << "Signature=#{Fog::AWS.escape(signature(params))}"
|
query << "Signature=#{Fog::AWS.escape(signature(params))}"
|
||||||
query << "Expires=#{params[:headers]['Date']}"
|
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]}"
|
port_part = params[:port] && ":#{params[:port]}"
|
||||||
"#{params[:scheme]}://#{params[:host]}#{port_part}/#{params[:path]}?#{query.join('&')}"
|
"#{params[:scheme]}://#{params[:host]}#{port_part}/#{params[:path]}?#{query.join('&')}"
|
||||||
end
|
end
|
||||||
|
@ -379,8 +381,8 @@ DATA
|
||||||
refresh_credentials_if_expired
|
refresh_credentials_if_expired
|
||||||
|
|
||||||
params[:headers]['Date'] = Fog::Time.now.to_date_header
|
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[:headers]['Authorization'] = "AWS #{@aws_access_key_id}:#{signature(params)}"
|
||||||
|
|
||||||
# FIXME: ToHashParser should make this not needed
|
# FIXME: ToHashParser should make this not needed
|
||||||
original_params = params.dup
|
original_params = params.dup
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue