dkim 1.0.0 → 1.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/.travis.yml +6 -5
- data/Appraisals +7 -0
- data/CHANGELOG.md +1 -1
- data/Gemfile +1 -7
- data/README.md +7 -3
- data/Rakefile +12 -0
- data/dkim.gemspec +5 -0
- data/gemfiles/mail_2.6.gemfile +11 -0
- data/gemfiles/mail_2.7.gemfile +11 -0
- data/lib/dkim.rb +1 -0
- data/lib/dkim/options.rb +6 -0
- data/lib/dkim/signed_mail.rb +1 -0
- data/lib/dkim/version.rb +1 -1
- data/lib/mail/dkim_field.rb +2 -2
- data/test/dkim/canonicalization_test.rb +1 -1
- data/test/dkim/canonicalized_headers_test.rb +1 -1
- data/test/dkim/dkim_header_test.rb +1 -1
- data/test/dkim/encodings_test.rb +1 -1
- data/test/dkim/interceptor_test.rb +5 -1
- data/test/dkim/options_test.rb +2 -1
- data/test/dkim/signed_mail_test.rb +16 -1
- data/test/dkim/tag_value_list_test.rb +1 -1
- metadata +69 -13
- data/Guardfile +0 -5
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: b79c96d0478fbf8b0034adf4e151e57eb0a54713
|
4
|
+
data.tar.gz: 416192a1854051a5b7bb772746f6824e866daebc
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7420d356c4fbf3281d942a67647ad778d6ab84704a681b32d6b422aa57e01884dfd8b86cc0326a96972d2fe116825efa5fddde26d149f9c090c7cf03d7933d11
|
7
|
+
data.tar.gz: 2d9edfbe6f3028af2aa4edfd92cb87b74aa4ae7dead5ae2b102cc53eff987f1a68b7f6175d2157ebb2b0f59b18164e10012a89d67c1aec2db2f1bd7e3baeeb80
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
data/Appraisals
ADDED
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
@@ -1,14 +1,8 @@
|
|
1
|
-
source
|
1
|
+
source 'https://rubygems.org'
|
2
2
|
|
3
3
|
# Specify your gem's dependencies in dkim.gemspec
|
4
4
|
gemspec
|
5
5
|
|
6
|
-
gem "rake"
|
7
|
-
gem 'minitest'
|
8
|
-
gem 'guard-minitest'
|
9
|
-
gem 'mail'
|
10
|
-
|
11
6
|
platforms :jruby do
|
12
7
|
gem 'jruby-openssl'
|
13
8
|
end
|
14
|
-
|
data/README.md
CHANGED
@@ -23,15 +23,19 @@ These can be specified globally
|
|
23
23
|
|
24
24
|
Options can be overridden per message.
|
25
25
|
|
26
|
-
Dkim.sign(mail, :selector => 'mail2', :private_key => open('private2.pem').read)
|
26
|
+
Dkim.sign(mail, :selector => 'mail2', :private_key => OpenSSL::PKey::RSA.new(open('private2.pem').read))
|
27
27
|
|
28
28
|
For more details see {Dkim::Options}
|
29
29
|
|
30
30
|
Usage With Rails
|
31
31
|
================
|
32
32
|
|
33
|
-
Dkim contains `Dkim::Interceptor` which can be used to sign all mail delivered
|
34
|
-
|
33
|
+
Dkim contains `Dkim::Interceptor` which can be used to sign all mail delivered
|
34
|
+
by [mail](https://github.com/mikel/mail), which is used by actionmailer in
|
35
|
+
rails >= 3.
|
36
|
+
|
37
|
+
For rails, create an initializer (for example `config/initializers/dkim.rb`)
|
38
|
+
with the following template.
|
35
39
|
|
36
40
|
# Configure dkim globally (see above)
|
37
41
|
Dkim::domain = 'example.com'
|
data/Rakefile
CHANGED
@@ -12,3 +12,15 @@ end
|
|
12
12
|
|
13
13
|
Bundler::GemHelper.install_tasks
|
14
14
|
|
15
|
+
desc 'Open an pry (or irb) session preloaded with Dkim'
|
16
|
+
task :console do
|
17
|
+
begin
|
18
|
+
require 'pry'
|
19
|
+
sh 'pry -I lib -r dkim.rb'
|
20
|
+
rescue LoadError => _
|
21
|
+
sh 'irb -rubygems -I lib -r dkim.rb'
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
task c: :console
|
data/dkim.gemspec
CHANGED
@@ -18,4 +18,9 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.test_files = `git ls-files -- test/*`.split("\n")
|
19
19
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
20
|
s.require_paths = ["lib"]
|
21
|
+
|
22
|
+
s.add_development_dependency 'rake'
|
23
|
+
s.add_development_dependency 'minitest', '~> 5.0'
|
24
|
+
s.add_development_dependency 'mail'
|
25
|
+
s.add_development_dependency 'appraisal'
|
21
26
|
end
|
data/lib/dkim.rb
CHANGED
data/lib/dkim/options.rb
CHANGED
@@ -39,6 +39,12 @@ module Dkim
|
|
39
39
|
# @return [String] domain
|
40
40
|
define_option_method :domain
|
41
41
|
|
42
|
+
# @attribute [rw]
|
43
|
+
# The identity used for signing.
|
44
|
+
# This corresponds to the i= tag in the dkim header.
|
45
|
+
# @return [String] identity
|
46
|
+
define_option_method :identity
|
47
|
+
|
42
48
|
# @attribute [rw]
|
43
49
|
# Selector used for signing.
|
44
50
|
# This corresponds to the s= tag in the dkim header.
|
data/lib/dkim/signed_mail.rb
CHANGED
@@ -59,6 +59,7 @@ module Dkim
|
|
59
59
|
dkim_header['a'] = signing_algorithm
|
60
60
|
dkim_header['c'] = "#{header_canonicalization}/#{body_canonicalization}"
|
61
61
|
dkim_header['d'] = domain
|
62
|
+
dkim_header['i'] = identity if identity
|
62
63
|
dkim_header['q'] = 'dns/txt'
|
63
64
|
dkim_header['s'] = selector
|
64
65
|
dkim_header['t'] = (time || Time.now).to_i
|
data/lib/dkim/version.rb
CHANGED
data/lib/mail/dkim_field.rb
CHANGED
@@ -9,7 +9,8 @@ module Mail
|
|
9
9
|
|
10
10
|
def initialize(value = nil, charset = 'utf-8')
|
11
11
|
self.charset = charset
|
12
|
-
|
12
|
+
value = strip_field(FIELD_NAME, value) if respond_to?(:strip_field)
|
13
|
+
super(CAPITALIZED_FIELD, value, charset)
|
13
14
|
self
|
14
15
|
end
|
15
16
|
|
@@ -22,4 +23,3 @@ module Mail
|
|
22
23
|
end
|
23
24
|
end
|
24
25
|
end
|
25
|
-
|
@@ -2,7 +2,7 @@
|
|
2
2
|
require 'test_helper'
|
3
3
|
|
4
4
|
module Dkim
|
5
|
-
class CanonicalizedHeadersTest <
|
5
|
+
class CanonicalizedHeadersTest < Minitest::Test
|
6
6
|
def test_maintains_order
|
7
7
|
headers = "ABCD".chars.map {|c| Header.new(c, c) }
|
8
8
|
header_keys = headers.map &:relaxed_key
|
data/test/dkim/encodings_test.rb
CHANGED
@@ -36,7 +36,7 @@ We lost the game. Are you hungry yet?
|
|
36
36
|
Joe.
|
37
37
|
eos
|
38
38
|
|
39
|
-
class InterceptorTest <
|
39
|
+
class InterceptorTest < Minitest::Test
|
40
40
|
def setup
|
41
41
|
@original_options = Dkim.options.dup
|
42
42
|
|
@@ -56,6 +56,7 @@ Joe.
|
|
56
56
|
Dkim.header_canonicalization = 'relaxed'
|
57
57
|
Dkim.body_canonicalization = 'relaxed'
|
58
58
|
Dkim.signing_algorithm = 'rsa-sha256'
|
59
|
+
Dkim.identity = '@example.com'
|
59
60
|
Interceptor.delivering_email(@mail)
|
60
61
|
dkim_header = @mail['DKIM-Signature']
|
61
62
|
|
@@ -63,6 +64,7 @@ Joe.
|
|
63
64
|
assert_includes dkim_header.to_s, 'rsa-sha256'
|
64
65
|
assert_includes dkim_header.to_s, 's=brisbane'
|
65
66
|
assert_includes dkim_header.to_s, 'd=example.com'
|
67
|
+
assert_includes dkim_header.to_s, 'i=@example.com'
|
66
68
|
assert_includes dkim_header.to_s, 'c=relaxed/relaxed'
|
67
69
|
assert_includes dkim_header.to_s, 'q=dns/txt'
|
68
70
|
assert_includes dkim_header.to_s, 'bh=2jUSOH9NhtVGCQWNr9BrIAPreKQjO6Sn7XIkfJVOzv8='
|
@@ -74,12 +76,14 @@ Joe.
|
|
74
76
|
Dkim.header_canonicalization = 'simple'
|
75
77
|
Dkim.body_canonicalization = 'simple'
|
76
78
|
Dkim.signing_algorithm = 'rsa-sha256'
|
79
|
+
Dkim.identity = '@example.com'
|
77
80
|
Interceptor.delivering_email(@mail)
|
78
81
|
dkim_header = @mail['DKIM-Signature']
|
79
82
|
assert dkim_header
|
80
83
|
assert_includes dkim_header.to_s, 'rsa-sha256'
|
81
84
|
assert_includes dkim_header.to_s, 's=brisbane'
|
82
85
|
assert_includes dkim_header.to_s, 'd=example.com'
|
86
|
+
assert_includes dkim_header.to_s, 'i=@example.com'
|
83
87
|
assert_includes dkim_header.to_s, 'c=simple/simple'
|
84
88
|
assert_includes dkim_header.to_s, 'q=dns/txt'
|
85
89
|
assert_includes dkim_header.to_s, 'bh=2jUSOH9NhtVGCQWNr9BrIAPreKQjO6Sn7XIkfJVOzv8='
|
data/test/dkim/options_test.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'test_helper'
|
2
2
|
|
3
3
|
module Dkim
|
4
|
-
class OptionsTest <
|
4
|
+
class OptionsTest < Minitest::Test
|
5
5
|
def setup
|
6
6
|
klass = Class.new
|
7
7
|
klass.send :include, Options
|
@@ -19,6 +19,7 @@ module Dkim
|
|
19
19
|
:signing_algorithm => 'abc123',
|
20
20
|
:signable_headers => [],
|
21
21
|
:domain => 'example.net',
|
22
|
+
:identity => '@example.net',
|
22
23
|
:selector => 'selector',
|
23
24
|
:time => 'time',
|
24
25
|
:header_canonicalization => 'simple',
|
@@ -2,7 +2,7 @@
|
|
2
2
|
require 'test_helper'
|
3
3
|
|
4
4
|
module Dkim
|
5
|
-
class SignedMailTest <
|
5
|
+
class SignedMailTest < Minitest::Test
|
6
6
|
def setup
|
7
7
|
@mail = EXAMPLEEMAIL.dup
|
8
8
|
end
|
@@ -46,6 +46,21 @@ module Dkim
|
|
46
46
|
assert_equal 't+dk4yxTI2ByZxxRzkwhZhM4WzTZjGWHiWnS2t4pg7oT7fAIlMrfihJ/CIvGmYqYv4lbq4LStHqHx9TmEgxrkjLevHtuqhxkN55xJ2vA2QzTzFi2fMDZ4fFqWy4QtvlLjBAhevG+LXpmjPYec1cyeMlHlPAthq5+RNi6NHErJiM=', dkim_header['b']
|
47
47
|
end
|
48
48
|
|
49
|
+
def test_identity
|
50
|
+
options = {
|
51
|
+
:domain => 'example.org',
|
52
|
+
:selector => 'sidney',
|
53
|
+
:identity => '@example.org',
|
54
|
+
:time => Time.at(1234567890)
|
55
|
+
}
|
56
|
+
signed_mail = SignedMail.new(@mail, options)
|
57
|
+
dkim_header = signed_mail.dkim_header.list
|
58
|
+
|
59
|
+
assert_equal '@example.org', dkim_header['i']
|
60
|
+
assert_equal '2jUSOH9NhtVGCQWNr9BrIAPreKQjO6Sn7XIkfJVOzv8=', dkim_header['bh']
|
61
|
+
assert_equal 'dCiulbJTD+GCCItMij1IU/RO0+q73afdjmrCWV5Qu7BIT5Kbp5Oi3jqCzj/v8Juks2/L6GBSXZia3aZprNVZX0szt8RnwC9NJx9WhcjN2RPz4Zf5F1jJivCN+PtaIWA3i3Ki/DR1q+RuNPgs7T1KKMo3Ih5uHubZIsMwRzbQBc0=', dkim_header['b']
|
62
|
+
end
|
63
|
+
|
49
64
|
def test_empty_body_hashes
|
50
65
|
@mail = @mail.split("\n\n").first + "\n\n"
|
51
66
|
|
metadata
CHANGED
@@ -1,16 +1,71 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dkim
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
version: 1.0.0
|
4
|
+
version: 1.0.1
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- John Hawthorn
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
13
|
-
dependencies:
|
11
|
+
date: 2017-11-16 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rake
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: minitest
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '5.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '5.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: mail
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: appraisal
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
14
69
|
description: gem for adding DKIM signatures to email messages
|
15
70
|
email:
|
16
71
|
- john.hawthorn@gmail.com
|
@@ -19,15 +74,17 @@ executables:
|
|
19
74
|
extensions: []
|
20
75
|
extra_rdoc_files: []
|
21
76
|
files:
|
22
|
-
- .gitignore
|
23
|
-
- .travis.yml
|
77
|
+
- ".gitignore"
|
78
|
+
- ".travis.yml"
|
79
|
+
- Appraisals
|
24
80
|
- CHANGELOG.md
|
25
81
|
- Gemfile
|
26
|
-
- Guardfile
|
27
82
|
- README.md
|
28
83
|
- Rakefile
|
29
84
|
- bin/dkimsign.rb
|
30
85
|
- dkim.gemspec
|
86
|
+
- gemfiles/mail_2.6.gemfile
|
87
|
+
- gemfiles/mail_2.7.gemfile
|
31
88
|
- lib/dkim.rb
|
32
89
|
- lib/dkim/body.rb
|
33
90
|
- lib/dkim/canonicalizable.rb
|
@@ -55,27 +112,26 @@ files:
|
|
55
112
|
- test/test_helper.rb
|
56
113
|
homepage: https://github.com/jhawthorn/dkim
|
57
114
|
licenses: []
|
115
|
+
metadata: {}
|
58
116
|
post_install_message:
|
59
117
|
rdoc_options: []
|
60
118
|
require_paths:
|
61
119
|
- lib
|
62
120
|
required_ruby_version: !ruby/object:Gem::Requirement
|
63
|
-
none: false
|
64
121
|
requirements:
|
65
|
-
- -
|
122
|
+
- - ">="
|
66
123
|
- !ruby/object:Gem::Version
|
67
124
|
version: '0'
|
68
125
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
|
-
none: false
|
70
126
|
requirements:
|
71
|
-
- -
|
127
|
+
- - ">="
|
72
128
|
- !ruby/object:Gem::Version
|
73
129
|
version: '0'
|
74
130
|
requirements: []
|
75
131
|
rubyforge_project: dkim
|
76
|
-
rubygems_version:
|
132
|
+
rubygems_version: 2.6.8
|
77
133
|
signing_key:
|
78
|
-
specification_version:
|
134
|
+
specification_version: 4
|
79
135
|
summary: DKIM library in ruby
|
80
136
|
test_files:
|
81
137
|
- test/dkim/canonicalization_test.rb
|