Skip to content

Commit 1c2bfc0

Browse files
committed
Merge pull request #8 from ahare/force-client-secret-to-string
Force the client_secret to be a string.
2 parents 6fc10e8 + 8847aac commit 1c2bfc0

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

lib/omniauth/strategies/salesforce.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ def request_phase
3434

3535
def auth_hash
3636
signed_value = access_token.params['id'] + access_token.params['issued_at']
37-
raw_expected_signature = OpenSSL::HMAC.digest('sha256', options.client_secret, signed_value)
37+
raw_expected_signature = OpenSSL::HMAC.digest('sha256', options.client_secret.to_s, signed_value)
3838
expected_signature = Base64.strict_encode64 raw_expected_signature
3939
signature = access_token.params['signature']
4040
fail! "Salesforce user id did not match signature!" unless signature == expected_signature
@@ -79,7 +79,7 @@ def raw_info
7979
'issued_at' => access_token.params['issued_at']
8080
})
8181
end
82-
82+
8383
end
8484

8585
class SalesforceSandbox < OmniAuth::Strategies::Salesforce

spec/omniauth/strategies/salesforce_spec.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@
1717
'REQUEST_METHOD' => 'GET',
1818
'rack.input' => '',
1919
'rack.url_scheme' => 'http',
20-
'SERVER_NAME' => 'server.example',
21-
'QUERY_STRING' => 'code=xxxx',
22-
'SCRIPT_NAME' => '',
20+
'SERVER_NAME' => 'server.example',
21+
'QUERY_STRING' => 'code=xxxx',
22+
'SCRIPT_NAME' => '',
2323
'SERVER_PORT' => 80
2424
}
2525
end
@@ -107,7 +107,7 @@
107107
it "returns an info hash" do
108108
subject.should_not be_nil
109109
end
110-
it "sets name" do
110+
it "sets name" do
111111
subject['name'].should == raw_info['display_name']
112112
end
113113
it "sets email" do
@@ -140,7 +140,7 @@
140140
end
141141
describe "credentials" do
142142
subject { strategy.credentials }
143-
it "sets token" do
143+
it "sets token" do
144144
subject['token'].should == strategy.access_token.token
145145
end
146146
it "sets instance_url" do
@@ -180,7 +180,7 @@
180180
before do
181181
client_id = "https://login.salesforce.com/id/00Dd0000000d45TEBQ/005d0000000fyGPCCY"
182182
issued_at = "1331142541514"
183-
signature = Base64.strict_encode64(OpenSSL::HMAC.digest('sha256', strategy.options.client_secret, client_id + issued_at))
183+
signature = Base64.strict_encode64(OpenSSL::HMAC.digest('sha256', strategy.options.client_secret.to_s, client_id + issued_at))
184184
end
185185
context "when the signature does not match" do
186186
before do

0 commit comments

Comments
 (0)