Skip to content

Commit

Permalink
Merge branch 'DianthuDia-support_unsigned_req_for_cognito-identity'
Browse files Browse the repository at this point in the history
  • Loading branch information
trevorrowe committed Jul 22, 2015
2 parents 794de72 + 3b6b118 commit ab0f7f5
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,18 @@ Unreleased Changes

See [related GitHub pull request #873](https://github.com/aws/aws-sdk-ruby/pull/873)

* Feature - Aws::CognitoIdentity - The following operations can now be called from
Aws::CognitoIdentity::Client without credentials:

* `#get_credentialsForIdentity`
* `#get_id`
* `#get_open_id_token`
* `#list_identity_pools`
* `#unlink_developer_identity`
* `#unlink_identity`

See [related GitHub pull request #862](https://github.com/aws/aws-sdk-ruby/pull/862)

2.1.7 (2015-07-14)
------------------

Expand Down
11 changes: 11 additions & 0 deletions aws-sdk-core/lib/aws-sdk-core/plugins/request_signer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,15 @@ class Handler < Seahorse::Client::Handler
AssumeRoleWithWebIdentity
))

COGNITO_IDENTITY_UNSIGNED_REQUESTS = Set.new(%w(
GetCredentialsForIdentity
GetId
GetOpenIdToken
ListIdentityPools
UnlinkDeveloperIdentity
UnlinkIdentity
))

def call(context)
sign_authenticated_requests(context) unless unsigned_request?(context)
@handler.call(context)
Expand Down Expand Up @@ -105,6 +114,8 @@ def unsigned_request?(context)
STS_UNSIGNED_REQUESTS.include?(context.operation.name)
elsif context.config.api.metadata['endpointPrefix'] == 'cloudsearchdomain'
context.config.credentials.nil? || !context.config.credentials.set?
elsif context.config.api.metadata['endpointPrefix'] == 'cognito-identity'
COGNITO_IDENTITY_UNSIGNED_REQUESTS.include?(context.operation.name)
else
false
end
Expand Down
21 changes: 21 additions & 0 deletions aws-sdk-core/spec/aws/cognito_identity/client_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
require 'spec_helper'

module Aws
module CognitoIdentity
describe Client do

let(:client) { Client.new(stub_responses: true, validate_params: false) }

Plugins::RequestSigner::Handler::COGNITO_IDENTITY_UNSIGNED_REQUESTS.each do |operation_name|
Seahorse::Util.underscore(operation_name).tap do |method_name|

it "does not sign calls to #{method_name}" do
resp = client.send(method_name, {})
expect(resp.context.http_request.headers['Authorization']).to be(nil)
end

end
end
end
end
end

0 comments on commit ab0f7f5

Please sign in to comment.