ahoy_email 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7d245ad6df5fbb64f6b38292b8b139a1382dda4e
4
- data.tar.gz: cd822e8f05cf9eb01a1c37979b67428c2c7fd999
3
+ metadata.gz: d979a2e35ab4b2d194f8e94b2ade4baf162ce2bf
4
+ data.tar.gz: 1345860269b934c01a1eba0eb309f15421db2450
5
5
  SHA512:
6
- metadata.gz: 7c598c2697d2ca2167e2ccb6e5fdedb20a27f831f71b0f7ed0a4907d9b4646e24f6cd02cdbb7be54328dfec81cf9b353d57a3c80bd08cbf21a510b58e3da4463
7
- data.tar.gz: a0649a7c6a0c575dc87a8aac7d36e1a53aab6d475c198a04131597001797442d1f3cdcedd442ec3f5f2ba4f64b3a2e4d9ab8d26af1d43d9984d7b060ea181d10
6
+ metadata.gz: 1a44602d1e85ac40b63b571f4b73b2b5630bb0cee93001f5fdef8c5e4bd5139d9882a102a0c774f799b33b7d2798d89fb684c8fb78dd5e90225b27c7c5994b8d
7
+ data.tar.gz: 73b8a764a5e953f977f9af13e04be7cdea32eecc5c952806615d1ce95ebc7c2f6583a822f598670b448261c46c4b424edba7249a564804862d897ac7f95212dc
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 0.1.1
2
+
3
+ - Use secure compare for signature verification
4
+ - Fixed deprecation warnings
5
+
1
6
  ## 0.1.0
2
7
 
3
8
  - First major release
data/README.md CHANGED
@@ -10,6 +10,8 @@ You get:
10
10
 
11
11
  Works with any email service.
12
12
 
13
+ :fire: To track visits and events, check out [Ahoy](https://github.com/ankane/ahoy) and [Ahoy Events](https://github.com/ankane/ahoy_events).
14
+
13
15
  ## Installation
14
16
 
15
17
  Add this line to your application’s Gemfile:
data/ahoy_email.gemspec CHANGED
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_dependency "actionmailer"
21
+ spec.add_dependency "rails"
22
22
  spec.add_dependency "addressable"
23
23
  spec.add_dependency "nokogiri"
24
24
 
@@ -16,8 +16,8 @@ module Ahoy
16
16
  @message.save!
17
17
  end
18
18
  url = params[:url]
19
- signature = OpenSSL::HMAC.hexdigest(OpenSSL::Digest::Digest.new("sha1"), AhoyEmail.secret_token, url)
20
- if params[:signature] == signature
19
+ signature = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new("sha1"), AhoyEmail.secret_token, url)
20
+ if secure_compare(params[:signature], signature)
21
21
  redirect_to url
22
22
  else
23
23
  redirect_to main_app.root_url
@@ -30,5 +30,17 @@ module Ahoy
30
30
  @message = AhoyEmail.message_model.where(token: params[:id]).first
31
31
  end
32
32
 
33
+ # from https://github.com/rails/rails/blob/master/activesupport/lib/active_support/message_verifier.rb
34
+ # constant-time comparison algorithm to prevent timing attacks
35
+ def secure_compare(a, b)
36
+ return false unless a.bytesize == b.bytesize
37
+
38
+ l = a.unpack "C#{a.bytesize}"
39
+
40
+ res = 0
41
+ b.each_byte { |byte| res |= byte ^ l.shift }
42
+ res == 0
43
+ end
44
+
33
45
  end
34
46
  end
@@ -89,7 +89,7 @@ module AhoyEmail
89
89
  end
90
90
 
91
91
  if options[:click] and !skip_attribute?(link, "click")
92
- signature = OpenSSL::HMAC.hexdigest(OpenSSL::Digest::Digest.new("sha1"), AhoyEmail.secret_token, link["href"])
92
+ signature = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new("sha1"), AhoyEmail.secret_token, link["href"])
93
93
  url =
94
94
  AhoyEmail::Engine.routes.url_helpers.url_for(
95
95
  Rails.application.config.action_mailer.default_url_options.merge(
@@ -1,3 +1,3 @@
1
1
  module AhoyEmail
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ahoy_email
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
@@ -11,7 +11,7 @@ cert_chain: []
11
11
  date: 2014-04-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: actionmailer
14
+ name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="