fog 1.24.0 → 1.25.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -13
- data/CHANGELOG.md +184 -1
- data/CONTRIBUTORS.md +23 -0
- data/README.md +17 -9
- data/Rakefile +4 -0
- data/fog.gemspec +18 -6
- data/lib/fog.rb +1 -1
- data/lib/fog/aws/auto_scaling.rb +12 -12
- data/lib/fog/aws/beanstalk.rb +12 -10
- data/lib/fog/aws/cdn.rb +0 -1
- data/lib/fog/aws/cloud_formation.rb +13 -11
- data/lib/fog/aws/cloud_watch.rb +14 -11
- data/lib/fog/aws/compute.rb +19 -19
- data/lib/fog/aws/core.rb +21 -0
- data/lib/fog/aws/dns.rb +0 -1
- data/lib/fog/aws/elasticache.rb +13 -9
- data/lib/fog/aws/elb.rb +23 -14
- data/lib/fog/aws/emr.rb +11 -9
- data/lib/fog/aws/iam.rb +14 -11
- data/lib/fog/aws/models/compute/security_group.rb +41 -0
- data/lib/fog/aws/models/elb/load_balancer.rb +31 -0
- data/lib/fog/aws/models/glacier/archive.rb +3 -1
- data/lib/fog/aws/models/iam/role.rb +1 -1
- data/lib/fog/aws/models/iam/roles.rb +1 -1
- data/lib/fog/aws/models/storage/file.rb +1 -1
- data/lib/fog/aws/parsers/compute/describe_security_groups.rb +68 -53
- data/lib/fog/aws/parsers/elb/describe_load_balancer_attributes.rb +7 -0
- data/lib/fog/aws/parsers/elb/describe_tags.rb +26 -0
- data/lib/fog/aws/parsers/elb/tag_list_parser.rb +57 -0
- data/lib/fog/aws/parsers/storage/get_bucket_website.rb +5 -1
- data/lib/fog/aws/rds.rb +13 -11
- data/lib/fog/aws/region_methods.rb +1 -1
- data/lib/fog/aws/requests/dynamodb/put_item.rb +1 -1
- data/lib/fog/aws/requests/elb/add_tags.rb +46 -0
- data/lib/fog/aws/requests/elb/create_load_balancer.rb +4 -1
- data/lib/fog/aws/requests/elb/describe_load_balancer_attributes.rb +3 -0
- data/lib/fog/aws/requests/elb/describe_tags.rb +56 -0
- data/lib/fog/aws/requests/elb/modify_load_balancer_attributes.rb +9 -3
- data/lib/fog/aws/requests/elb/remove_tags.rb +46 -0
- data/lib/fog/aws/requests/storage/copy_object.rb +1 -1
- data/lib/fog/aws/requests/storage/delete_object.rb +4 -3
- data/lib/fog/aws/requests/storage/post_object_hidden_fields.rb +23 -5
- data/lib/fog/aws/requests/storage/post_object_restore.rb +1 -1
- data/lib/fog/aws/requests/storage/put_bucket_website.rb +46 -18
- data/lib/fog/aws/ses.rb +1 -2
- data/lib/fog/aws/signaturev4.rb +62 -15
- data/lib/fog/aws/simpledb.rb +0 -1
- data/lib/fog/aws/sns.rb +12 -9
- data/lib/fog/aws/sqs.rb +14 -10
- data/lib/fog/aws/storage.rb +102 -78
- data/lib/fog/aws/sts.rb +10 -9
- data/lib/fog/bare_metal_cloud/compute.rb +0 -1
- data/lib/fog/bin.rb +1 -0
- data/lib/fog/bin/brightbox.rb +3 -1
- data/lib/fog/bin/rackspace.rb +4 -0
- data/lib/fog/bluebox/models/compute/server.rb +1 -0
- data/lib/fog/cloudstack/models/compute/server.rb +12 -1
- data/lib/fog/cloudstack/models/compute/snapshots.rb +3 -2
- data/lib/fog/cloudstack/models/compute/volume.rb +5 -0
- data/lib/fog/cloudstack/models/compute/volumes.rb +3 -2
- data/lib/fog/core/parser.rb +2 -112
- data/lib/fog/dnsmadeeasy/dns.rb +0 -1
- data/lib/fog/dynect/core.rb +0 -1
- data/lib/fog/dynect/dns.rb +11 -3
- data/lib/fog/ecloud/compute.rb +0 -1
- data/lib/fog/ecloud/core.rb +1 -1
- data/lib/fog/fogdocker/compute.rb +4 -1
- data/lib/fog/fogdocker/core.rb +1 -7
- data/lib/fog/fogdocker/errors.rb +9 -0
- data/lib/fog/fogdocker/models/compute/images.rb +4 -0
- data/lib/fog/fogdocker/models/compute/server.rb +18 -1
- data/lib/fog/fogdocker/requests/compute/container_action.rb +53 -3
- data/lib/fog/fogdocker/requests/compute/container_get.rb +31 -12
- data/lib/fog/fogdocker/requests/compute/image_search.rb +29 -0
- data/lib/fog/google/dns.rb +46 -12
- data/lib/fog/google/examples/dns/project.rb +8 -0
- data/lib/fog/google/examples/dns/zones.rb +43 -0
- data/lib/fog/google/models/compute/images.rb +2 -1
- data/lib/fog/google/models/dns/change.rb +40 -0
- data/lib/fog/google/models/dns/changes.rb +52 -0
- data/lib/fog/google/models/dns/project.rb +75 -0
- data/lib/fog/google/models/dns/projects.rb +25 -0
- data/lib/fog/google/models/dns/record.rb +112 -0
- data/lib/fog/google/models/dns/records.rb +52 -0
- data/lib/fog/google/models/dns/zone.rb +74 -0
- data/lib/fog/google/models/dns/zones.rb +34 -0
- data/lib/fog/google/models/storage/file.rb +1 -1
- data/lib/fog/google/models/storage/files.rb +1 -5
- data/lib/fog/google/requests/dns/create_change.rb +64 -0
- data/lib/fog/google/requests/dns/create_managed_zone.rb +64 -31
- data/lib/fog/google/requests/dns/delete_managed_zone.rb +20 -24
- data/lib/fog/google/requests/dns/get_change.rb +42 -0
- data/lib/fog/google/requests/dns/get_managed_zone.rb +22 -16
- data/lib/fog/google/requests/dns/get_project.rb +42 -0
- data/lib/fog/google/requests/dns/list_changes.rb +41 -0
- data/lib/fog/google/requests/dns/list_managed_zones.rb +15 -10
- data/lib/fog/google/requests/dns/list_resource_record_sets.rb +50 -0
- data/lib/fog/google/storage.rb +0 -1
- data/lib/fog/hp/storage.rb +1 -1
- data/lib/fog/internet_archive/storage.rb +0 -1
- data/lib/fog/libvirt/models/compute/server.rb +17 -7
- data/lib/fog/opennebula/models/compute/flavor.rb +46 -8
- data/lib/fog/opennebula/models/compute/flavors.rb +7 -0
- data/lib/fog/opennebula/models/compute/interface.rb +1 -1
- data/lib/fog/opennebula/models/compute/network.rb +1 -0
- data/lib/fog/opennebula/models/compute/networks.rb +5 -1
- data/lib/fog/opennebula/requests/compute/list_networks.rb +34 -25
- data/lib/fog/opennebula/requests/compute/template_pool.rb +47 -5
- data/lib/fog/openstack/compute.rb +2 -2
- data/lib/fog/openstack/docs/storage.md +18 -0
- data/lib/fog/openstack/identity.rb +1 -1
- data/lib/fog/openstack/image.rb +1 -1
- data/lib/fog/openstack/metering.rb +1 -1
- data/lib/fog/openstack/models/compute/server.rb +1 -0
- data/lib/fog/openstack/models/storage/directory.rb +8 -2
- data/lib/fog/openstack/network.rb +1 -1
- data/lib/fog/openstack/orchestration.rb +1 -1
- data/lib/fog/openstack/requests/compute/create_security_group.rb +1 -1
- data/lib/fog/openstack/requests/storage/public_url.rb +28 -0
- data/lib/fog/openstack/requests/storage/put_container.rb +1 -0
- data/lib/fog/openstack/storage.rb +1 -0
- data/lib/fog/openstack/volume.rb +1 -1
- data/lib/fog/ovirt/compute.rb +1 -0
- data/lib/fog/ovirt/models/compute/server.rb +5 -0
- data/lib/fog/ovirt/requests/compute/update_volume.rb +39 -0
- data/lib/fog/rackspace.rb +1 -0
- data/lib/fog/rackspace/core.rb +1 -0
- data/lib/fog/rackspace/docs/networking.md +315 -0
- data/lib/fog/rackspace/mock_data.rb +1 -2
- data/lib/fog/rackspace/models/dns/zones.rb +2 -1
- data/lib/fog/rackspace/models/load_balancers/node.rb +7 -0
- data/lib/fog/rackspace/models/networking/network.rb +27 -0
- data/lib/fog/rackspace/models/networking/networks.rb +23 -0
- data/lib/fog/rackspace/models/networking/virtual_interface.rb +85 -0
- data/lib/fog/rackspace/models/networking/virtual_interfaces.rb +45 -0
- data/lib/fog/rackspace/models/queues/queue.rb +1 -1
- data/lib/fog/rackspace/networking.rb +192 -0
- data/lib/fog/rackspace/requests/load_balancers/create_node.rb +3 -0
- data/lib/fog/rackspace/requests/load_balancers/update_node.rb +3 -0
- data/lib/fog/rackspace/requests/networking/create_network.rb +36 -0
- data/lib/fog/rackspace/requests/networking/create_virtual_interface.rb +30 -0
- data/lib/fog/rackspace/requests/networking/delete_network.rb +21 -0
- data/lib/fog/rackspace/requests/networking/delete_virtual_interface.rb +23 -0
- data/lib/fog/rackspace/requests/networking/get_network.rb +21 -0
- data/lib/fog/rackspace/requests/networking/list_networks.rb +18 -0
- data/lib/fog/rackspace/requests/networking/list_virtual_interfaces.rb +22 -0
- data/lib/fog/vcloud/compute.rb +0 -1
- data/lib/fog/vcloud/core.rb +1 -0
- data/lib/fog/vcloud_director/compute.rb +1 -1
- data/lib/fog/version.rb +1 -1
- data/lib/fog/vsphere/compute.rb +38 -1
- data/lib/fog/vsphere/requests/compute/list_clusters.rb +31 -1
- data/lib/fog/vsphere/requests/compute/modify_vm_interface.rb +1 -1
- data/lib/fog/zerigo/dns.rb +0 -1
- data/lib/tasks/changelog_task.rb +1 -0
- data/tests/aws/models/elb/model_tests.rb +6 -0
- data/tests/aws/models/elb/tagging_tests.rb +15 -0
- data/tests/aws/models/iam/access_keys_tests.rb +1 -1
- data/tests/aws/models/iam/policies_tests.rb +2 -1
- data/tests/aws/models/iam/users_tests.rb +7 -4
- data/tests/aws/models/storage/url_tests.rb +5 -9
- data/tests/aws/requests/compute/tag_tests.rb +2 -0
- data/tests/aws/requests/elb/load_balancer_tests.rb +5 -1
- data/tests/aws/requests/storage/bucket_tests.rb +15 -1
- data/tests/aws/signaturev4_tests.rb +47 -0
- data/tests/bluebox/requests/compute/block_tests.rb +2 -1
- data/tests/compute/helper.rb +0 -10
- data/tests/compute/models/flavors_tests.rb +1 -1
- data/tests/fogdocker/compute_tests.rb +1 -1
- data/tests/fogdocker/models/compute/server_tests.rb +13 -3
- data/tests/fogdocker/requests/compute/container_action_tests.rb +19 -8
- data/tests/fogdocker/requests/compute/image_search_tests.rb +11 -0
- data/tests/google/models/dns/change_tests.rb +28 -0
- data/tests/google/models/dns/changes_tests.rb +36 -0
- data/tests/google/models/dns/projects_tests.rb +12 -0
- data/tests/google/models/dns/record_tests.rb +42 -0
- data/tests/google/models/dns/records_tests.rb +36 -0
- data/tests/google/models/dns/zone_tests.rb +28 -0
- data/tests/google/models/dns/zones_tests.rb +14 -0
- data/tests/google/requests/dns/change_tests.rb +86 -0
- data/tests/google/requests/dns/managed_zone_tests.rb +1 -1
- data/tests/google/requests/dns/project_tests.rb +29 -0
- data/tests/google/requests/dns/record_tests.rb +49 -0
- data/tests/helper.rb +1 -1
- data/tests/helpers/mock_helper.rb +2 -2
- data/tests/opennebula/models/compute/flavor_tests.rb +29 -0
- data/tests/opennebula/models/compute/flavors_tests.rb +17 -0
- data/tests/opennebula/models/compute/network_tests.rb +2 -2
- data/tests/opennebula/models/compute/networks_tests.rb +2 -0
- data/tests/openstack/requests/storage/object_tests.rb +10 -0
- data/tests/ovirt/compute_tests.rb +1 -1
- data/tests/ovirt/requests/compute/update_volume_tests.rb +20 -0
- data/tests/rackspace/models/networking/network_tests.rb +10 -0
- data/tests/rackspace/models/networking/networks_tests.rb +10 -0
- data/tests/rackspace/models/networking/virtual_interface_tests.rb +33 -0
- data/tests/rackspace/models/networking/virtual_interfaces_tests.rb +24 -0
- data/tests/rackspace/models/queues/queue_tests.rb +9 -0
- data/tests/rackspace/networking_tests.rb +118 -0
- data/tests/rackspace/requests/networking/network_tests.rb +49 -0
- data/tests/rackspace/requests/networking/virtual_interface_tests.rb +49 -0
- data/tests/vsphere/requests/compute/list_clusters_tests.rb +11 -0
- metadata +228 -180
- data/lib/fog/bin/terremark.rb +0 -29
- data/lib/fog/bin/vmfusion.rb +0 -58
- data/lib/fog/bin/voxel.rb +0 -29
- data/lib/fog/terremark.rb +0 -11
- data/lib/fog/terremark/models/shared/address.rb +0 -25
- data/lib/fog/terremark/models/shared/addresses.rb +0 -45
- data/lib/fog/terremark/models/shared/image.rb +0 -19
- data/lib/fog/terremark/models/shared/images.rb +0 -41
- data/lib/fog/terremark/models/shared/internetservice.rb +0 -66
- data/lib/fog/terremark/models/shared/internetservices.rb +0 -39
- data/lib/fog/terremark/models/shared/network.rb +0 -31
- data/lib/fog/terremark/models/shared/networks.rb +0 -48
- data/lib/fog/terremark/models/shared/nodeservice.rb +0 -50
- data/lib/fog/terremark/models/shared/nodeservices.rb +0 -29
- data/lib/fog/terremark/models/shared/server.rb +0 -210
- data/lib/fog/terremark/models/shared/servers.rb +0 -50
- data/lib/fog/terremark/models/shared/task.rb +0 -46
- data/lib/fog/terremark/models/shared/tasks.rb +0 -54
- data/lib/fog/terremark/models/shared/vdc.rb +0 -40
- data/lib/fog/terremark/models/shared/vdcs.rb +0 -48
- data/lib/fog/terremark/parser.rb +0 -18
- data/lib/fog/terremark/parsers/shared/get_catalog.rb +0 -33
- data/lib/fog/terremark/parsers/shared/get_catalog_item.rb +0 -32
- data/lib/fog/terremark/parsers/shared/get_internet_services.rb +0 -57
- data/lib/fog/terremark/parsers/shared/get_keys_list.rb +0 -39
- data/lib/fog/terremark/parsers/shared/get_network_ips.rb +0 -24
- data/lib/fog/terremark/parsers/shared/get_node_services.rb +0 -32
- data/lib/fog/terremark/parsers/shared/get_organization.rb +0 -50
- data/lib/fog/terremark/parsers/shared/get_organizations.rb +0 -31
- data/lib/fog/terremark/parsers/shared/get_public_ips.rb +0 -26
- data/lib/fog/terremark/parsers/shared/get_tasks_list.rb +0 -35
- data/lib/fog/terremark/parsers/shared/get_vapp_template.rb +0 -31
- data/lib/fog/terremark/parsers/shared/get_vdc.rb +0 -87
- data/lib/fog/terremark/parsers/shared/instantiate_vapp_template.rb +0 -26
- data/lib/fog/terremark/parsers/shared/internet_service.rb +0 -58
- data/lib/fog/terremark/parsers/shared/network.rb +0 -39
- data/lib/fog/terremark/parsers/shared/node_service.rb +0 -28
- data/lib/fog/terremark/parsers/shared/public_ip.rb +0 -22
- data/lib/fog/terremark/parsers/shared/task.rb +0 -25
- data/lib/fog/terremark/parsers/shared/vapp.rb +0 -61
- data/lib/fog/terremark/requests/shared/add_internet_service.rb +0 -54
- data/lib/fog/terremark/requests/shared/add_node_service.rb +0 -51
- data/lib/fog/terremark/requests/shared/configure_vapp.rb +0 -59
- data/lib/fog/terremark/requests/shared/create_internet_service.rb +0 -59
- data/lib/fog/terremark/requests/shared/delete_internet_service.rb +0 -21
- data/lib/fog/terremark/requests/shared/delete_node_service.rb +0 -21
- data/lib/fog/terremark/requests/shared/delete_public_ip.rb +0 -21
- data/lib/fog/terremark/requests/shared/delete_vapp.rb +0 -20
- data/lib/fog/terremark/requests/shared/deploy_vapp.rb +0 -33
- data/lib/fog/terremark/requests/shared/get_catalog.rb +0 -30
- data/lib/fog/terremark/requests/shared/get_catalog_item.rb +0 -33
- data/lib/fog/terremark/requests/shared/get_internet_services.rb +0 -34
- data/lib/fog/terremark/requests/shared/get_keys_list.rb +0 -34
- data/lib/fog/terremark/requests/shared/get_network.rb +0 -69
- data/lib/fog/terremark/requests/shared/get_network_ips.rb +0 -29
- data/lib/fog/terremark/requests/shared/get_node_services.rb +0 -29
- data/lib/fog/terremark/requests/shared/get_organization.rb +0 -82
- data/lib/fog/terremark/requests/shared/get_organizations.rb +0 -45
- data/lib/fog/terremark/requests/shared/get_public_ip.rb +0 -31
- data/lib/fog/terremark/requests/shared/get_public_ips.rb +0 -68
- data/lib/fog/terremark/requests/shared/get_task.rb +0 -37
- data/lib/fog/terremark/requests/shared/get_tasks_list.rb +0 -30
- data/lib/fog/terremark/requests/shared/get_vapp.rb +0 -40
- data/lib/fog/terremark/requests/shared/get_vapp_template.rb +0 -33
- data/lib/fog/terremark/requests/shared/get_vdc.rb +0 -121
- data/lib/fog/terremark/requests/shared/instantiate_vapp_template.rb +0 -79
- data/lib/fog/terremark/requests/shared/power_off.rb +0 -33
- data/lib/fog/terremark/requests/shared/power_on.rb +0 -33
- data/lib/fog/terremark/requests/shared/power_reset.rb +0 -33
- data/lib/fog/terremark/requests/shared/power_shutdown.rb +0 -22
- data/lib/fog/terremark/shared.rb +0 -304
- data/lib/fog/terremark/vcloud.rb +0 -129
- data/lib/fog/vmfusion.rb +0 -1
- data/lib/fog/vmfusion/compute.rb +0 -28
- data/lib/fog/vmfusion/core.rb +0 -9
- data/lib/fog/vmfusion/models/compute/server.rb +0 -256
- data/lib/fog/vmfusion/models/compute/servers.rb +0 -36
- data/lib/fog/voxel.rb +0 -1
- data/lib/fog/voxel/compute.rb +0 -122
- data/lib/fog/voxel/core.rb +0 -16
- data/lib/fog/voxel/models/compute/image.rb +0 -13
- data/lib/fog/voxel/models/compute/images.rb +0 -27
- data/lib/fog/voxel/models/compute/server.rb +0 -73
- data/lib/fog/voxel/models/compute/servers.rb +0 -29
- data/lib/fog/voxel/parsers/compute/basic.rb +0 -27
- data/lib/fog/voxel/parsers/compute/devices_list.rb +0 -107
- data/lib/fog/voxel/parsers/compute/images_list.rb +0 -55
- data/lib/fog/voxel/parsers/compute/voxcloud_create.rb +0 -36
- data/lib/fog/voxel/parsers/compute/voxcloud_delete.rb +0 -27
- data/lib/fog/voxel/parsers/compute/voxcloud_status.rb +0 -42
- data/lib/fog/voxel/requests/compute/devices_list.rb +0 -22
- data/lib/fog/voxel/requests/compute/devices_power.rb +0 -20
- data/lib/fog/voxel/requests/compute/images_list.rb +0 -29
- data/lib/fog/voxel/requests/compute/voxcloud_create.rb +0 -20
- data/lib/fog/voxel/requests/compute/voxcloud_delete.rb +0 -18
- data/lib/fog/voxel/requests/compute/voxcloud_status.rb +0 -22
- data/lib/fog/xml.rb +0 -4
- data/lib/fog/xml/connection.rb +0 -24
- data/lib/fog/xml/sax_parser_connection.rb +0 -45
- data/tests/core/connection_tests.rb +0 -26
- data/tests/voxel/requests/compute/image_tests.rb +0 -52
- data/tests/voxel/requests/compute/server_tests.rb +0 -123
@@ -14,9 +14,9 @@ module Fog
|
|
14
14
|
|
15
15
|
def delete_object(bucket_name, object_name, options = {})
|
16
16
|
if version_id = options.delete('versionId')
|
17
|
-
|
17
|
+
query = {'versionId' => version_id}
|
18
18
|
else
|
19
|
-
|
19
|
+
query = {}
|
20
20
|
end
|
21
21
|
|
22
22
|
headers = options
|
@@ -24,9 +24,10 @@ module Fog
|
|
24
24
|
:expects => 204,
|
25
25
|
:headers => headers,
|
26
26
|
:bucket_name => bucket_name,
|
27
|
+
:object_name => object_name,
|
27
28
|
:idempotent => true,
|
28
29
|
:method => 'DELETE',
|
29
|
-
:
|
30
|
+
:query => query
|
30
31
|
})
|
31
32
|
end
|
32
33
|
end
|
@@ -23,12 +23,30 @@ module Fog
|
|
23
23
|
# @see http://docs.amazonwebservices.com/AmazonS3/latest/dev/HTTPPOSTForms.html
|
24
24
|
#
|
25
25
|
def post_object_hidden_fields(options = {})
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
26
|
+
options = options.dup
|
27
|
+
if policy = options['policy']
|
28
|
+
date = Fog::Time.now
|
29
|
+
credential = "#{@aws_access_key_id}/#{@signer.credential_scope(date)}"
|
30
|
+
extra_conditions = [
|
31
|
+
{'x-amz-date' => date.to_iso8601_basic},
|
32
|
+
{'x-amz-credential' => credential},
|
33
|
+
{'x-amz-algorithm' => Fog::AWS::SignatureV4::ALGORITHM}
|
34
|
+
]
|
35
|
+
|
36
|
+
extra_conditions << {'x-amz-security-token' => @aws_session_token } if @aws_session_token
|
37
|
+
|
38
|
+
policy_with_auth_fields = policy.merge('conditions' => policy['conditions'] + extra_conditions)
|
39
|
+
|
40
|
+
options['policy'] = Base64.encode64(Fog::JSON.encode(policy_with_auth_fields)).gsub("\n", "")
|
41
|
+
options['X-Amz-Credential'] = credential
|
42
|
+
options['X-Amz-Date'] = date.to_iso8601_basic
|
43
|
+
options['X-Amz-Algorithm'] = Fog::AWS::SignatureV4::ALGORITHM
|
44
|
+
if @aws_session_token
|
45
|
+
options['X-Amz-Security-Token'] = @aws_session_token
|
46
|
+
end
|
47
|
+
options['X-Amz-Signature'] = @signer.derived_hmac(date).sign(options['policy']).unpack('H*').first
|
30
48
|
end
|
31
|
-
options
|
49
|
+
options
|
32
50
|
end
|
33
51
|
end
|
34
52
|
end
|
@@ -5,28 +5,56 @@ module Fog
|
|
5
5
|
# Change website configuration for an S3 bucket
|
6
6
|
#
|
7
7
|
# @param bucket_name [String] name of bucket to modify
|
8
|
-
# @param suffix [String] suffix to append to requests for the bucket
|
9
8
|
# @param options [Hash]
|
10
|
-
# @option options
|
9
|
+
# @option options RedirectAllRequestsTo [String] Host name to redirect all requests to - if this is set, other options are ignored
|
10
|
+
# @option options IndexDocument [String] suffix to append to requests for the bucket
|
11
|
+
# @option options ErrorDocument [String] key to use for 4XX class errors
|
11
12
|
#
|
12
13
|
# @see http://docs.amazonwebservices.com/AmazonS3/latest/API/RESTBucketPUTwebsite.html
|
13
14
|
|
14
|
-
def put_bucket_website(bucket_name,
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
15
|
+
def put_bucket_website(bucket_name, options, options_to_be_deprecated = {})
|
16
|
+
options ||= {}
|
17
|
+
|
18
|
+
# Method used to be called with the suffix as the second parameter. Warn user that this is not the case any more and move on
|
19
|
+
if options.is_a?(String)
|
20
|
+
Fog::Logger.deprecation("put_bucket_website with #{options.class} param is deprecated, use put_bucket_website('#{bucket_name}', :IndexDocument => '#{options}') instead [light_black](#{caller.first})[/]")
|
21
|
+
options = { :IndexDocument => options }
|
22
|
+
end
|
23
|
+
|
24
|
+
# Parameter renamed from "key" to "ErrorDocument"
|
25
|
+
if options_to_be_deprecated[:key]
|
26
|
+
Fog::Logger.deprecation("put_bucket_website with three parameters is deprecated, use put_bucket_website('#{bucket_name}', :ErrorDocument => '#{options_to_be_deprecated[:key]}') instead [light_black](#{caller.first})[/]")
|
27
|
+
options[:ErrorDocument] = options_to_be_deprecated[:key]
|
28
|
+
end
|
29
|
+
|
30
|
+
options.merge!(options_to_be_deprecated) { |key, o1, o2| o1 }
|
31
|
+
|
32
|
+
data = "<WebsiteConfiguration xmlns=\"http://s3.amazonaws.com/doc/2006-03-01/\">"
|
33
|
+
|
34
|
+
if options[:RedirectAllRequestsTo]
|
35
|
+
# Redirect precludes all other options
|
36
|
+
data << <<-DATA
|
37
|
+
<RedirectAllRequestsTo>
|
38
|
+
<HostName>#{options[:RedirectAllRequestsTo]}</HostName>
|
39
|
+
</RedirectAllRequestsTo>
|
40
|
+
DATA
|
41
|
+
else
|
42
|
+
|
43
|
+
if options[:IndexDocument]
|
44
|
+
data << <<-DATA
|
45
|
+
<IndexDocument>
|
46
|
+
<Suffix>#{options[:IndexDocument]}</Suffix>
|
47
|
+
</IndexDocument>
|
48
|
+
DATA
|
49
|
+
end
|
50
|
+
|
51
|
+
if options[:ErrorDocument]
|
52
|
+
data << <<-DATA
|
53
|
+
<ErrorDocument>
|
54
|
+
<Key>#{options[:ErrorDocument]}</Key>
|
55
|
+
</ErrorDocument>
|
56
|
+
DATA
|
57
|
+
end
|
30
58
|
end
|
31
59
|
|
32
60
|
data << '</WebsiteConfiguration>'
|
data/lib/fog/aws/ses.rb
CHANGED
@@ -48,7 +48,6 @@ module Fog
|
|
48
48
|
# ==== Returns
|
49
49
|
# * SES object with connection to AWS.
|
50
50
|
def initialize(options={})
|
51
|
-
require 'fog/core/parser'
|
52
51
|
|
53
52
|
@use_iam_profile = options[:use_iam_profile]
|
54
53
|
setup_credentials(options)
|
@@ -114,7 +113,7 @@ module Fog
|
|
114
113
|
end
|
115
114
|
end
|
116
115
|
|
117
|
-
def
|
116
|
+
def _request(body, headers, idempotent, parser)
|
118
117
|
@connection.request({
|
119
118
|
:body => body,
|
120
119
|
:expects => 200,
|
data/lib/fog/aws/signaturev4.rb
CHANGED
@@ -4,6 +4,7 @@ require 'fog/aws/core'
|
|
4
4
|
module Fog
|
5
5
|
module AWS
|
6
6
|
class SignatureV4
|
7
|
+
ALGORITHM = 'AWS4-HMAC-SHA256'
|
7
8
|
def initialize(aws_access_key_id, secret_key, region,service)
|
8
9
|
@region = region
|
9
10
|
@service = service
|
@@ -11,33 +12,86 @@ module Fog
|
|
11
12
|
@hmac = Fog::HMAC.new('sha256', 'AWS4' + secret_key)
|
12
13
|
end
|
13
14
|
|
14
|
-
def
|
15
|
+
def signature_parameters(params, date, body_sha = nil)
|
16
|
+
params = params.dup.merge(:query => params[:query].merge(
|
17
|
+
'X-Amz-Algorithm' => ALGORITHM,
|
18
|
+
'X-Amz-Credential' => "#{@aws_access_key_id}/#{credential_scope(date)}",
|
19
|
+
'X-Amz-SignedHeaders' => signed_headers(params[:headers])
|
20
|
+
))
|
21
|
+
signature_components(params, date, body_sha)
|
22
|
+
end
|
23
|
+
|
24
|
+
def signature_header(params, date, body_sha = nil)
|
25
|
+
components_to_header(signature_components(params, date, body_sha))
|
26
|
+
end
|
27
|
+
|
28
|
+
def sign(params, date) #legacy method name
|
29
|
+
signature_header(params, date)
|
30
|
+
end
|
31
|
+
|
32
|
+
def components_to_header components
|
33
|
+
"#{components['X-Amz-Algorithm']} Credential=#{components['X-Amz-Credential']}, SignedHeaders=#{components['X-Amz-SignedHeaders']}, Signature=#{components['X-Amz-Signature']}"
|
34
|
+
end
|
35
|
+
|
36
|
+
def signature_components(params, date, body_sha)
|
15
37
|
canonical_request = <<-DATA
|
16
38
|
#{params[:method].to_s.upcase}
|
17
|
-
#{params[:path]}
|
39
|
+
#{canonical_path(params[:path])}
|
18
40
|
#{canonical_query_string(params[:query])}
|
19
41
|
#{canonical_headers(params[:headers])}
|
20
42
|
#{signed_headers(params[:headers])}
|
21
|
-
#{Digest::SHA256.hexdigest(params[:body] || '')}
|
43
|
+
#{body_sha || Digest::SHA256.hexdigest(params[:body] || '')}
|
22
44
|
DATA
|
23
45
|
canonical_request.chop!
|
24
|
-
|
46
|
+
|
25
47
|
string_to_sign = <<-DATA
|
26
|
-
|
48
|
+
#{ALGORITHM}
|
27
49
|
#{date.to_iso8601_basic}
|
28
|
-
#{credential_scope}
|
50
|
+
#{credential_scope(date)}
|
29
51
|
#{Digest::SHA256.hexdigest(canonical_request)}
|
30
52
|
DATA
|
31
53
|
|
32
54
|
string_to_sign.chop!
|
33
|
-
|
55
|
+
|
34
56
|
signature = derived_hmac(date).sign(string_to_sign)
|
35
57
|
|
36
|
-
|
58
|
+
{
|
59
|
+
'X-Amz-Algorithm' => ALGORITHM,
|
60
|
+
'X-Amz-Credential' => "#{@aws_access_key_id}/#{credential_scope(date)}",
|
61
|
+
'X-Amz-SignedHeaders' => signed_headers(params[:headers]),
|
62
|
+
'X-Amz-Signature' => signature.unpack('H*').first
|
63
|
+
}
|
64
|
+
end
|
65
|
+
|
66
|
+
def derived_hmac(date)
|
67
|
+
kDate = @hmac.sign(date.utc.strftime('%Y%m%d'))
|
68
|
+
kRegion = Fog::HMAC.new('sha256', kDate).sign(@region)
|
69
|
+
kService = Fog::HMAC.new('sha256', kRegion).sign(@service)
|
70
|
+
kSigning = Fog::HMAC.new('sha256', kService).sign('aws4_request')
|
71
|
+
Fog::HMAC.new('sha256', kSigning)
|
72
|
+
end
|
73
|
+
|
74
|
+
|
75
|
+
def credential_scope(date)
|
76
|
+
"#{date.utc.strftime('%Y%m%d')}/#{@region}/#{@service}/aws4_request"
|
37
77
|
end
|
38
78
|
|
39
79
|
protected
|
40
80
|
|
81
|
+
def canonical_path(path)
|
82
|
+
components = path.split(%r{/+}, -1)
|
83
|
+
path = components.inject([]) do |acc, component|
|
84
|
+
case component
|
85
|
+
when '.' #canonicalize by removing .
|
86
|
+
when '..' then acc.pop#canonicalize by reducing ..
|
87
|
+
else
|
88
|
+
acc << component
|
89
|
+
end
|
90
|
+
acc
|
91
|
+
end.join('/')
|
92
|
+
path.empty? ? '/' : path
|
93
|
+
end
|
94
|
+
|
41
95
|
def canonical_query_string(query)
|
42
96
|
canonical_query_string = []
|
43
97
|
for key in (query || {}).keys.sort_by {|k| k.to_s}
|
@@ -60,13 +114,6 @@ DATA
|
|
60
114
|
headers.keys.map {|key| key.to_s}.sort.map {|key| key.downcase}.join(';')
|
61
115
|
end
|
62
116
|
|
63
|
-
def derived_hmac(date)
|
64
|
-
kDate = @hmac.sign(date.utc.strftime('%Y%m%d'))
|
65
|
-
kRegion = Fog::HMAC.new('sha256', kDate).sign(@region)
|
66
|
-
kService = Fog::HMAC.new('sha256', kRegion).sign(@service)
|
67
|
-
kSigning = Fog::HMAC.new('sha256', kService).sign('aws4_request')
|
68
|
-
Fog::HMAC.new('sha256', kSigning)
|
69
|
-
end
|
70
117
|
end
|
71
118
|
end
|
72
119
|
end
|
data/lib/fog/aws/simpledb.rb
CHANGED
data/lib/fog/aws/sns.rb
CHANGED
@@ -49,12 +49,12 @@ module Fog
|
|
49
49
|
# * SNS object with connection to AWS.
|
50
50
|
def initialize(options={})
|
51
51
|
@use_iam_profile = options[:use_iam_profile]
|
52
|
-
setup_credentials(options)
|
53
52
|
@connection_options = options[:connection_options] || {}
|
54
53
|
@instrumentor = options[:instrumentor]
|
55
54
|
@instrumentor_name = options[:instrumentor_name] || 'fog.aws.sns'
|
56
55
|
|
57
56
|
options[:region] ||= 'us-east-1'
|
57
|
+
@region = options[:region]
|
58
58
|
@host = options[:host] || "sns.#{options[:region]}.amazonaws.com"
|
59
59
|
|
60
60
|
@path = options[:path] || '/'
|
@@ -62,6 +62,8 @@ module Fog
|
|
62
62
|
@port = options[:port] || 443
|
63
63
|
@scheme = options[:scheme] || 'https'
|
64
64
|
@connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options)
|
65
|
+
|
66
|
+
setup_credentials(options)
|
65
67
|
end
|
66
68
|
|
67
69
|
def reload
|
@@ -76,7 +78,7 @@ module Fog
|
|
76
78
|
@aws_session_token = options[:aws_session_token]
|
77
79
|
@aws_credentials_expire_at = options[:aws_credentials_expire_at]
|
78
80
|
|
79
|
-
@
|
81
|
+
@signer = Fog::AWS::SignatureV4.new( @aws_access_key_id, @aws_secret_access_key, @region, 'sns')
|
80
82
|
end
|
81
83
|
|
82
84
|
def request(params)
|
@@ -85,12 +87,13 @@ module Fog
|
|
85
87
|
idempotent = params.delete(:idempotent)
|
86
88
|
parser = params.delete(:parser)
|
87
89
|
|
88
|
-
body = AWS.
|
90
|
+
body, headers = AWS.signed_params_v4(
|
89
91
|
params,
|
92
|
+
{ 'Content-Type' => 'application/x-www-form-urlencoded' },
|
90
93
|
{
|
91
|
-
:
|
94
|
+
:method => 'POST',
|
92
95
|
:aws_session_token => @aws_session_token,
|
93
|
-
:
|
96
|
+
:signer => @signer,
|
94
97
|
:host => @host,
|
95
98
|
:path => @path,
|
96
99
|
:port => @port
|
@@ -99,19 +102,19 @@ module Fog
|
|
99
102
|
|
100
103
|
if @instrumentor
|
101
104
|
@instrumentor.instrument("#{@instrumentor_name}.request", params) do
|
102
|
-
_request(body, idempotent, parser)
|
105
|
+
_request(body, headers, idempotent, parser)
|
103
106
|
end
|
104
107
|
else
|
105
|
-
_request(body, idempotent, parser)
|
108
|
+
_request(body, headers, idempotent, parser)
|
106
109
|
end
|
107
110
|
end
|
108
111
|
|
109
|
-
def _request(body, idempotent, parser)
|
112
|
+
def _request(body, headers, idempotent, parser)
|
110
113
|
@connection.request({
|
111
114
|
:body => body,
|
112
115
|
:expects => 200,
|
113
116
|
:idempotent => idempotent,
|
114
|
-
:headers =>
|
117
|
+
:headers => headers,
|
115
118
|
:method => 'POST',
|
116
119
|
:parser => parser
|
117
120
|
})
|
data/lib/fog/aws/sqs.rb
CHANGED
@@ -40,7 +40,7 @@ module Fog
|
|
40
40
|
setup_credentials(options)
|
41
41
|
@region = options[:region] || 'us-east-1'
|
42
42
|
|
43
|
-
unless ['ap-northeast-1', 'ap-southeast-1', 'ap-southeast-2', 'eu-west-1', 'us-east-1', 'us-west-1', 'us-west-2', 'sa-east-1'].include?(@region)
|
43
|
+
unless ['ap-northeast-1', 'ap-southeast-1', 'ap-southeast-2', 'eu-central-1', 'eu-west-1', 'us-east-1', 'us-west-1', 'us-west-2', 'sa-east-1'].include?(@region)
|
44
44
|
raise ArgumentError, "Unknown region: #{@region.inspect}"
|
45
45
|
end
|
46
46
|
end
|
@@ -80,11 +80,11 @@ module Fog
|
|
80
80
|
# * SQS object with connection to AWS.
|
81
81
|
def initialize(options={})
|
82
82
|
@use_iam_profile = options[:use_iam_profile]
|
83
|
-
setup_credentials(options)
|
84
83
|
@instrumentor = options[:instrumentor]
|
85
84
|
@instrumentor_name = options[:instrumentor_name] || 'fog.aws.sqs'
|
86
85
|
@connection_options = options[:connection_options] || {}
|
87
86
|
options[:region] ||= 'us-east-1'
|
87
|
+
@region = options[:region]
|
88
88
|
@host = options[:host] || "sqs.#{options[:region]}.amazonaws.com"
|
89
89
|
|
90
90
|
@path = options[:path] || '/'
|
@@ -92,6 +92,8 @@ module Fog
|
|
92
92
|
@port = options[:port] || 443
|
93
93
|
@scheme = options[:scheme] || 'https'
|
94
94
|
@connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}#{@path}", @persistent, @connection_options)
|
95
|
+
|
96
|
+
setup_credentials(options)
|
95
97
|
end
|
96
98
|
|
97
99
|
def reload
|
@@ -105,7 +107,8 @@ module Fog
|
|
105
107
|
@aws_secret_access_key = options[:aws_secret_access_key]
|
106
108
|
@aws_session_token = options[:aws_session_token]
|
107
109
|
@aws_credentials_expire_at = options[:aws_credentials_expire_at]
|
108
|
-
|
110
|
+
|
111
|
+
@signer = Fog::AWS::SignatureV4.new( @aws_access_key_id, @aws_secret_access_key, @region, 'sqs')
|
109
112
|
end
|
110
113
|
|
111
114
|
def path_from_queue_url(queue_url)
|
@@ -119,12 +122,13 @@ module Fog
|
|
119
122
|
parser = params.delete(:parser)
|
120
123
|
path = params.delete(:path)
|
121
124
|
|
122
|
-
body = AWS.
|
125
|
+
body, headers = AWS.signed_params_v4(
|
123
126
|
params,
|
127
|
+
{ 'Content-Type' => 'application/x-www-form-urlencoded' },
|
124
128
|
{
|
125
|
-
:
|
129
|
+
:method => 'POST',
|
126
130
|
:aws_session_token => @aws_session_token,
|
127
|
-
:
|
131
|
+
:signer => @signer,
|
128
132
|
:host => @host,
|
129
133
|
:path => path || @path,
|
130
134
|
:port => @port,
|
@@ -134,19 +138,19 @@ module Fog
|
|
134
138
|
|
135
139
|
if @instrumentor
|
136
140
|
@instrumentor.instrument("#{@instrumentor_name}.request", params) do
|
137
|
-
_request(body, idempotent, parser, path)
|
141
|
+
_request(body, headers, idempotent, parser, path)
|
138
142
|
end
|
139
143
|
else
|
140
|
-
_request(body, idempotent, parser, path)
|
144
|
+
_request(body, headers, idempotent, parser, path)
|
141
145
|
end
|
142
146
|
end
|
143
147
|
|
144
|
-
def _request(body, idempotent, parser, path)
|
148
|
+
def _request(body, headers, idempotent, parser, path)
|
145
149
|
args = {
|
146
150
|
:body => body,
|
147
151
|
:expects => 200,
|
148
152
|
:idempotent => idempotent,
|
149
|
-
:headers =>
|
153
|
+
:headers => headers,
|
150
154
|
:method => 'POST',
|
151
155
|
:parser => parser,
|
152
156
|
:path => path
|
data/lib/fog/aws/storage.rb
CHANGED
@@ -138,20 +138,26 @@ module Fog
|
|
138
138
|
end
|
139
139
|
|
140
140
|
def signed_url(params, expires)
|
141
|
-
expires
|
141
|
+
#convert expires from a point in time to a delta to now
|
142
|
+
now = Fog::Time.now
|
143
|
+
|
144
|
+
expires = expires.to_i - now.to_i
|
145
|
+
params[:headers] ||= {}
|
146
|
+
|
147
|
+
params[:query]||= {}
|
148
|
+
params[:query]['X-Amz-Expires'] = expires
|
149
|
+
params[:query]['X-Amz-Date'] = now.to_iso8601_basic
|
150
|
+
|
142
151
|
if @aws_session_token
|
143
|
-
params[:
|
144
|
-
params[:headers]['x-amz-security-token'] = @aws_session_token
|
152
|
+
params[:query]['X-Amz-Security-Token'] = @aws_session_token
|
145
153
|
end
|
146
|
-
|
154
|
+
|
147
155
|
params = request_params(params)
|
156
|
+
params[:headers][:host] = params[:host]
|
148
157
|
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
'Expires' => expires,
|
153
|
-
})
|
154
|
-
params[:query]['x-amz-security-token'] = @aws_session_token if @aws_session_token
|
158
|
+
signature = @signer.signature_parameters(params, now, "UNSIGNED-PAYLOAD")
|
159
|
+
|
160
|
+
params[:query] = (params[:query] || {}).merge(signature)
|
155
161
|
|
156
162
|
params_to_url(params)
|
157
163
|
end
|
@@ -217,7 +223,10 @@ module Fog
|
|
217
223
|
if !path_style && COMPLIANT_BUCKET_NAMES !~ bucket_name
|
218
224
|
Fog::Logger.warning("fog: the specified s3 bucket name(#{bucket_name}) is not a valid dns name, which will negatively impact performance. For details see: http://docs.amazonwebservices.com/AmazonS3/latest/dev/BucketRestrictions.html")
|
219
225
|
path_style = true
|
220
|
-
|
226
|
+
elsif scheme == 'https' && bucket_name =~ /\./
|
227
|
+
Fog::Logger.warning("fog: the specified s3 bucket name(#{bucket_name}) contains a '.' so is not accessible over https as a virtual hosted bucket, which will negatively impact performance. For details see: http://docs.amazonwebservices.com/AmazonS3/latest/dev/BucketRestrictions.html")
|
228
|
+
path_style = true
|
229
|
+
end
|
221
230
|
|
222
231
|
if path_style
|
223
232
|
path = bucket_to_path bucket_name, path
|
@@ -351,7 +360,6 @@ module Fog
|
|
351
360
|
|
352
361
|
def initialize(options={})
|
353
362
|
@use_iam_profile = options[:use_iam_profile]
|
354
|
-
setup_credentials(options)
|
355
363
|
if @endpoint = options[:endpoint]
|
356
364
|
endpoint = URI.parse(@endpoint)
|
357
365
|
@host = endpoint.host
|
@@ -364,6 +372,7 @@ module Fog
|
|
364
372
|
@port = options[:port] || DEFAULT_SCHEME_PORT[@scheme]
|
365
373
|
end
|
366
374
|
@path_style = options[:path_style] || false
|
375
|
+
setup_credentials(options)
|
367
376
|
end
|
368
377
|
|
369
378
|
def data
|
@@ -374,15 +383,13 @@ module Fog
|
|
374
383
|
self.class.data[@region].delete(@aws_access_key_id)
|
375
384
|
end
|
376
385
|
|
377
|
-
def signature(params, expires)
|
378
|
-
"foo"
|
379
|
-
end
|
380
|
-
|
381
386
|
def setup_credentials(options)
|
382
387
|
@aws_access_key_id = options[:aws_access_key_id]
|
383
388
|
@aws_secret_access_key = options[:aws_secret_access_key]
|
384
389
|
@aws_session_token = options[:aws_session_token]
|
385
390
|
@aws_credentials_expire_at = options[:aws_credentials_expire_at]
|
391
|
+
|
392
|
+
@signer = Fog::AWS::SignatureV4.new( @aws_access_key_id, @aws_secret_access_key, @region, 's3')
|
386
393
|
end
|
387
394
|
end
|
388
395
|
|
@@ -408,10 +415,8 @@ module Fog
|
|
408
415
|
# ==== Returns
|
409
416
|
# * S3 object with connection to aws.
|
410
417
|
def initialize(options={})
|
411
|
-
require 'fog/core/parser'
|
412
418
|
|
413
419
|
@use_iam_profile = options[:use_iam_profile]
|
414
|
-
setup_credentials(options)
|
415
420
|
@instrumentor = options[:instrumentor]
|
416
421
|
@instrumentor_name = options[:instrumentor_name] || 'fog.aws.storage'
|
417
422
|
@connection_options = options[:connection_options] || {}
|
@@ -430,67 +435,14 @@ module Fog
|
|
430
435
|
@scheme = options[:scheme] || DEFAULT_SCHEME
|
431
436
|
@port = options[:port] || DEFAULT_SCHEME_PORT[@scheme]
|
432
437
|
end
|
438
|
+
|
439
|
+
setup_credentials(options)
|
433
440
|
end
|
434
441
|
|
435
442
|
def reload
|
436
443
|
@connection.reset if @connection
|
437
444
|
end
|
438
445
|
|
439
|
-
def signature(params, expires)
|
440
|
-
headers = params[:headers] || {}
|
441
|
-
|
442
|
-
string_to_sign =
|
443
|
-
<<-DATA
|
444
|
-
#{params[:method].to_s.upcase}
|
445
|
-
#{headers['Content-MD5']}
|
446
|
-
#{headers['Content-Type']}
|
447
|
-
#{expires}
|
448
|
-
DATA
|
449
|
-
|
450
|
-
amz_headers, canonical_amz_headers = {}, ''
|
451
|
-
for key, value in headers
|
452
|
-
if key[0..5] == 'x-amz-'
|
453
|
-
amz_headers[key] = value
|
454
|
-
end
|
455
|
-
end
|
456
|
-
amz_headers = amz_headers.sort {|x, y| x[0] <=> y[0]}
|
457
|
-
for key, value in amz_headers
|
458
|
-
canonical_amz_headers << "#{key}:#{value}\n"
|
459
|
-
end
|
460
|
-
string_to_sign << canonical_amz_headers
|
461
|
-
|
462
|
-
query_string = ''
|
463
|
-
if params[:query]
|
464
|
-
query_args = []
|
465
|
-
for key in params[:query].keys.sort
|
466
|
-
if VALID_QUERY_KEYS.include?(key)
|
467
|
-
value = params[:query][key]
|
468
|
-
if value
|
469
|
-
query_args << "#{key}=#{value}"
|
470
|
-
else
|
471
|
-
query_args << key
|
472
|
-
end
|
473
|
-
end
|
474
|
-
end
|
475
|
-
if query_args.any?
|
476
|
-
query_string = '?' + query_args.join('&')
|
477
|
-
end
|
478
|
-
end
|
479
|
-
|
480
|
-
canonical_path = (params[:path] || object_to_path(params[:object_name])).to_s
|
481
|
-
canonical_path = '/' + canonical_path if canonical_path[0..0] != '/'
|
482
|
-
if params[:bucket_name]
|
483
|
-
canonical_resource = "/#{params[:bucket_name]}#{canonical_path}"
|
484
|
-
else
|
485
|
-
canonical_resource = canonical_path
|
486
|
-
end
|
487
|
-
canonical_resource << query_string
|
488
|
-
string_to_sign << canonical_resource
|
489
|
-
|
490
|
-
signed_string = @hmac.sign(string_to_sign)
|
491
|
-
Base64.encode64(signed_string).chomp!
|
492
|
-
end
|
493
|
-
|
494
446
|
private
|
495
447
|
|
496
448
|
def setup_credentials(options)
|
@@ -499,7 +451,7 @@ DATA
|
|
499
451
|
@aws_session_token = options[:aws_session_token]
|
500
452
|
@aws_credentials_expire_at = options[:aws_credentials_expire_at]
|
501
453
|
|
502
|
-
@
|
454
|
+
@signer = Fog::AWS::SignatureV4.new( @aws_access_key_id, @aws_secret_access_key, @region, 's3')
|
503
455
|
end
|
504
456
|
|
505
457
|
def connection(scheme, host, port)
|
@@ -519,21 +471,43 @@ DATA
|
|
519
471
|
def request(params, &block)
|
520
472
|
refresh_credentials_if_expired
|
521
473
|
|
522
|
-
|
474
|
+
date = Fog::Time.now
|
475
|
+
|
476
|
+
params = params.dup
|
477
|
+
params[:headers] = (params[:headers] || {}).dup
|
523
478
|
|
524
479
|
params[:headers]['x-amz-security-token'] = @aws_session_token if @aws_session_token
|
525
|
-
|
480
|
+
|
481
|
+
if params[:body].respond_to?(:read)
|
482
|
+
# See http://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-streaming.html
|
483
|
+
params[:headers]['x-amz-content-sha256'] = 'STREAMING-AWS4-HMAC-SHA256-PAYLOAD'
|
484
|
+
params[:headers]['x-amz-decoded-content-length'] = params[:headers].delete 'Content-Length'
|
485
|
+
|
486
|
+
encoding = "aws-chunked"
|
487
|
+
|
488
|
+
encoding += ", #{params[:headers]['Content-Encoding']}" if params[:headers]['Content-Encoding']
|
489
|
+
params[:headers]['Content-Encoding'] = encoding
|
490
|
+
else
|
491
|
+
params[:headers]['x-amz-content-sha256'] ||= Digest::SHA256.hexdigest(params[:body] || '')
|
492
|
+
end
|
493
|
+
params[:headers]['x-amz-date'] = date.to_iso8601_basic
|
526
494
|
|
527
495
|
params = request_params(params)
|
528
496
|
scheme = params.delete(:scheme)
|
529
497
|
host = params.delete(:host)
|
530
498
|
port = params.delete(:port) || DEFAULT_SCHEME_PORT[scheme]
|
499
|
+
params[:headers]['Host'] = host
|
531
500
|
|
532
|
-
params[:headers]['
|
533
|
-
params[:headers]['Authorization'] =
|
501
|
+
signature_components = @signer.signature_components(params, date, params[:headers]['x-amz-content-sha256'])
|
502
|
+
params[:headers]['Authorization'] = @signer.components_to_header(signature_components)
|
534
503
|
# FIXME: ToHashParser should make this not needed
|
535
504
|
original_params = params.dup
|
536
505
|
|
506
|
+
if params[:body].respond_to?(:read)
|
507
|
+
body = params.delete :body
|
508
|
+
params[:request_block] = S3Streamer.new(body, signature_components['X-Amz-Signature'], @signer, date)
|
509
|
+
end
|
510
|
+
|
537
511
|
if @instrumentor
|
538
512
|
@instrumentor.instrument("#{@instrumentor_name}.request", params) do
|
539
513
|
_request(scheme, host, port, params, original_params, &block)
|
@@ -551,6 +525,56 @@ DATA
|
|
551
525
|
Fog::Logger.warning("fog: followed redirect to #{uri.host}, connecting to the matching region will be more performant")
|
552
526
|
Fog::XML::Connection.new("#{uri.scheme}://#{uri.host}:#{uri.port}", false, @connection_options).request(original_params, &block)
|
553
527
|
end
|
528
|
+
|
529
|
+
# See http://docs.aws.amazon.com/AmazonS3/latest/API/sigv4-streaming.html
|
530
|
+
|
531
|
+
class S3Streamer
|
532
|
+
attr_accessor :body, :signature, :signer, :finished, :date
|
533
|
+
def initialize(body, signature, signer, date)
|
534
|
+
self.body = body
|
535
|
+
self.date = date
|
536
|
+
self.signature = signature
|
537
|
+
self.signer = signer
|
538
|
+
if body.respond_to?(:binmode)
|
539
|
+
body.binmode
|
540
|
+
end
|
541
|
+
if body.respond_to?(:pos=)
|
542
|
+
body.pos = 0
|
543
|
+
end
|
544
|
+
end
|
545
|
+
|
546
|
+
def call
|
547
|
+
if finished
|
548
|
+
''
|
549
|
+
else
|
550
|
+
next_chunk
|
551
|
+
end
|
552
|
+
end
|
553
|
+
|
554
|
+
def next_chunk
|
555
|
+
data = body.read(0x10000)
|
556
|
+
if data.nil?
|
557
|
+
self.finished = true
|
558
|
+
data = ''
|
559
|
+
end
|
560
|
+
self.signature = sign_chunk(data, signature)
|
561
|
+
"#{data.length.to_s(16)};chunk-signature=#{signature}\r\n#{data}\r\n"
|
562
|
+
end
|
563
|
+
|
564
|
+
|
565
|
+
def sign_chunk(data, previous_signature)
|
566
|
+
string_to_sign = <<-DATA
|
567
|
+
AWS4-HMAC-SHA256-PAYLOAD
|
568
|
+
#{date.to_iso8601_basic}
|
569
|
+
#{signer.credential_scope(date)}
|
570
|
+
#{previous_signature}
|
571
|
+
#{Digest::SHA256.hexdigest('')}
|
572
|
+
#{Digest::SHA256.hexdigest(data)}
|
573
|
+
DATA
|
574
|
+
hmac = signer.derived_hmac(date)
|
575
|
+
hmac.sign(string_to_sign.strip).unpack('H*').first
|
576
|
+
end
|
577
|
+
end
|
554
578
|
end
|
555
579
|
end
|
556
580
|
end
|