mail-gpg 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +0 -1
- data/.travis.yml +7 -0
- data/History.txt +6 -0
- data/README.md +17 -17
- data/gemfiles/rails3.gemfile +10 -0
- data/gemfiles/rails4.gemfile +11 -0
- data/lib/mail/gpg/delivery_handler.rb +17 -3
- data/lib/mail/gpg/message_patch.rb +5 -1
- data/lib/mail/gpg/version.rb +1 -1
- data/lib/mail/gpg/version_part.rb +1 -1
- data/test/action_mailer_test.rb +2 -2
- data/test/gpg_test.rb +1 -1
- data/test/gpghome/pubring.gpg +0 -0
- data/test/gpghome/pubring.gpg~ +0 -0
- data/test/gpghome/random_seed +0 -0
- data/test/gpghome/secring.gpg +0 -0
- data/test/gpghome/trustdb.gpg +0 -0
- data/test/message_test.rb +2 -2
- data/test/test_helper.rb +5 -1
- metadata +15 -2
data/.gitignore
CHANGED
data/.travis.yml
ADDED
data/History.txt
CHANGED
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Mail::Gpg
|
1
|
+
# Mail::Gpg [](https://travis-ci.org/jkraemer/mail-gpg)
|
2
2
|
|
3
3
|
This gem adds GPG/MIME encryption capabilities to the [Ruby Mail
|
4
4
|
Library](https://github.com/mikel/mail)
|
@@ -32,19 +32,19 @@ with the gpg method:
|
|
32
32
|
add_file "some_attachment.zip"
|
33
33
|
|
34
34
|
# encrypt message, no signing
|
35
|
-
gpg true
|
35
|
+
gpg encrypt: true
|
36
36
|
|
37
37
|
# encrypt and sign message with sender's private key, using the given
|
38
38
|
# passphrase to decrypt the key
|
39
|
-
gpg sign: true, password: 'secret'
|
39
|
+
gpg encrypt: true, sign: true, password: 'secret'
|
40
40
|
|
41
41
|
# encrypt and sign message using a different key
|
42
|
-
gpg sign_as: 'joe@otherdomain.com', password: 'secret'
|
42
|
+
gpg encrypt: true, sign_as: 'joe@otherdomain.com', password: 'secret'
|
43
43
|
|
44
44
|
|
45
45
|
# encrypt and sign message and use a callback function to provide the
|
46
46
|
# passphrase.
|
47
|
-
gpg sign_as: 'joe@otherdomain.com',
|
47
|
+
gpg encrypt: true, sign_as: 'joe@otherdomain.com',
|
48
48
|
passphrase_callback: ->(obj, uid_hint, passphrase_info, prev_was_bad, fd){puts "Enter passphrase for #{passphrase_info}: "; (IO.for_fd(fd, 'w') << readline.chomp).flush }
|
49
49
|
end.deliver
|
50
50
|
|
@@ -64,11 +64,11 @@ armored key data for recipients using the `:keys` option like this:
|
|
64
64
|
|
65
65
|
Mail.new do
|
66
66
|
to 'john@foo.bar'
|
67
|
-
gpg keys: { 'john@foo.bar' => johns_key }
|
67
|
+
gpg encrypt: true, keys: { 'john@foo.bar' => johns_key }
|
68
68
|
end
|
69
69
|
|
70
70
|
The key will then be imported before actually trying to encrypt/send the mail.
|
71
|
-
|
71
|
+
In theory you only need to specify the key once like that, however doing it
|
72
72
|
every time does not hurt as gpg is clever enough to recognize known keys, only
|
73
73
|
updating it's db when necessary.
|
74
74
|
|
@@ -85,7 +85,7 @@ This is not implemented yet
|
|
85
85
|
class MyMailer < ActionMailer::Base
|
86
86
|
default from: 'baz@bar.com'
|
87
87
|
def some_mail
|
88
|
-
mail to: 'foo@bar.com', subject: 'subject!', gpg: true
|
88
|
+
mail to: 'foo@bar.com', subject: 'subject!', gpg: { encrypt: true }
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
@@ -96,19 +96,19 @@ Mail::Message#gpg method.
|
|
96
96
|
|
97
97
|
bundle exec rake
|
98
98
|
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
therefore be substantially faster.
|
99
|
+
Test cases use a mock gpghome located in `test/gpghome` in order to not mess
|
100
|
+
around with your personal gpg keychain.
|
101
|
+
|
103
102
|
|
104
103
|
## Todo
|
105
104
|
|
106
105
|
* Signing of unencrypted mails
|
107
|
-
* Decryption
|
108
|
-
*
|
109
|
-
*
|
110
|
-
|
111
|
-
|
106
|
+
* Decryption and signature verification for received mails
|
107
|
+
* on the fly import of recipients' keys from public key servers based on email address or key id
|
108
|
+
* handle encryption errors due to missing keys - maybe return a list of failed
|
109
|
+
recipients
|
110
|
+
* add some setup code to help initialize a basic keychain directory with
|
111
|
+
public/private keypair.
|
112
112
|
|
113
113
|
|
114
114
|
## Contributing
|
@@ -6,12 +6,26 @@ module Mail
|
|
6
6
|
if mail.gpg
|
7
7
|
encrypted_mail = nil
|
8
8
|
begin
|
9
|
-
options = TrueClass === mail.gpg ? {} : mail.gpg
|
10
|
-
|
9
|
+
options = TrueClass === mail.gpg ? { encrypt: true } : mail.gpg
|
10
|
+
if options.delete(:encrypt)
|
11
|
+
encrypted_mail = Mail::Gpg.encrypt(mail, options)
|
12
|
+
elsif options[:sign] || options[:sign_as]
|
13
|
+
raise "signing without encryption is not supported yet"
|
14
|
+
else
|
15
|
+
# encrypt and sign are off -> do not encrypt or sign
|
16
|
+
yield
|
17
|
+
end
|
11
18
|
rescue Exception
|
12
19
|
raise $! if mail.raise_encryption_errors
|
13
20
|
end
|
14
|
-
|
21
|
+
if encrypted_mail
|
22
|
+
if dm = mail.delivery_method
|
23
|
+
encrypted_mail.instance_variable_set :@delivery_method, dm
|
24
|
+
end
|
25
|
+
encrypted_mail.perform_deliveries = mail.perform_deliveries
|
26
|
+
encrypted_mail.raise_delivery_errors = mail.raise_delivery_errors
|
27
|
+
encrypted_mail.deliver
|
28
|
+
end
|
15
29
|
else
|
16
30
|
yield
|
17
31
|
end
|
@@ -21,7 +21,11 @@ module Mail
|
|
21
21
|
# See Mail::Gpg methods encrypt and sign for more
|
22
22
|
# possible options
|
23
23
|
#
|
24
|
-
# mail.gpg true
|
24
|
+
# mail.gpg encrypt: true
|
25
|
+
# mail.gpg encrypt: true, sign: true
|
26
|
+
# mail.gpg encrypt: true, sign_as: "other_address@host.com"
|
27
|
+
#
|
28
|
+
# future versions will also support sign-only mode:
|
25
29
|
# mail.gpg sign_as: 'jane@doe.com', encrypt: false
|
26
30
|
#
|
27
31
|
# To turn off gpg encryption use:
|
data/lib/mail/gpg/version.rb
CHANGED
data/test/action_mailer_test.rb
CHANGED
@@ -8,7 +8,7 @@ class MyMailer < ActionMailer::Base
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def encrypted
|
11
|
-
mail subject: 'encrypted', body: 'encrypted mail', gpg: true
|
11
|
+
mail subject: 'encrypted', body: 'encrypted mail', gpg: {encrypt: true}
|
12
12
|
end
|
13
13
|
|
14
14
|
|
@@ -30,7 +30,7 @@ class ActionMailerTest < Test::Unit::TestCase
|
|
30
30
|
|
31
31
|
should "send encrypted mail" do
|
32
32
|
assert m = MyMailer.encrypted
|
33
|
-
assert true == m.gpg
|
33
|
+
assert true == m.gpg[:encrypt]
|
34
34
|
m.deliver
|
35
35
|
assert_equal 1, @emails.size
|
36
36
|
assert m = @emails.first
|
data/test/gpg_test.rb
CHANGED
@@ -13,7 +13,7 @@ class GpgTest < Test::Unit::TestCase
|
|
13
13
|
assert_equal 2, encrypted.parts.size
|
14
14
|
v_part, enc_part = encrypted.parts
|
15
15
|
|
16
|
-
assert_match /Version 1/, v_part.to_s
|
16
|
+
assert_match /Version: 1/, v_part.to_s
|
17
17
|
assert_equal 'application/pgp-encrypted; charset=UTF-8', v_part.content_type
|
18
18
|
|
19
19
|
assert_equal 'application/octet-stream; name=encrypted.asc',
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
data/test/message_test.rb
CHANGED
@@ -29,7 +29,7 @@ class MessageTest < Test::Unit::TestCase
|
|
29
29
|
|
30
30
|
context "with gpg turned on" do
|
31
31
|
setup do
|
32
|
-
@mail.gpg true
|
32
|
+
@mail.gpg encrypt: true
|
33
33
|
end
|
34
34
|
|
35
35
|
context "with missing key" do
|
@@ -77,7 +77,7 @@ class MessageTest < Test::Unit::TestCase
|
|
77
77
|
|
78
78
|
should "set and unset delivery_handler" do
|
79
79
|
m = Mail.new do
|
80
|
-
gpg true
|
80
|
+
gpg encrypt: true
|
81
81
|
end
|
82
82
|
assert m.gpg
|
83
83
|
assert dh = m.delivery_handler
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mail-gpg
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-08-
|
12
|
+
date: 2013-08-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mail
|
@@ -134,11 +134,14 @@ extensions: []
|
|
134
134
|
extra_rdoc_files: []
|
135
135
|
files:
|
136
136
|
- .gitignore
|
137
|
+
- .travis.yml
|
137
138
|
- Gemfile
|
138
139
|
- History.txt
|
139
140
|
- LICENSE.txt
|
140
141
|
- README.md
|
141
142
|
- Rakefile
|
143
|
+
- gemfiles/rails3.gemfile
|
144
|
+
- gemfiles/rails4.gemfile
|
142
145
|
- lib/hkp.rb
|
143
146
|
- lib/mail-gpg.rb
|
144
147
|
- lib/mail/gpg.rb
|
@@ -152,6 +155,11 @@ files:
|
|
152
155
|
- mail-gpg.gemspec
|
153
156
|
- test/action_mailer_test.rb
|
154
157
|
- test/gpg_test.rb
|
158
|
+
- test/gpghome/pubring.gpg
|
159
|
+
- test/gpghome/pubring.gpg~
|
160
|
+
- test/gpghome/random_seed
|
161
|
+
- test/gpghome/secring.gpg
|
162
|
+
- test/gpghome/trustdb.gpg
|
155
163
|
- test/message_test.rb
|
156
164
|
- test/test_helper.rb
|
157
165
|
homepage: https://github.com/jkraemer/mail-gpg
|
@@ -182,5 +190,10 @@ summary: GPG/MIME encryption plugin for the Ruby Mail Library
|
|
182
190
|
test_files:
|
183
191
|
- test/action_mailer_test.rb
|
184
192
|
- test/gpg_test.rb
|
193
|
+
- test/gpghome/pubring.gpg
|
194
|
+
- test/gpghome/pubring.gpg~
|
195
|
+
- test/gpghome/random_seed
|
196
|
+
- test/gpghome/secring.gpg
|
197
|
+
- test/gpghome/trustdb.gpg
|
185
198
|
- test/message_test.rb
|
186
199
|
- test/test_helper.rb
|