enmail 0.1.0 → 0.2.0
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.
- checksums.yaml +5 -5
- data/.editorconfig +21 -0
- data/.gitignore +164 -9
- data/.gitmodules +3 -0
- data/.rubocop.yml +26 -627
- data/.travis.yml +86 -3
- data/.yardopts +6 -0
- data/Gemfile +10 -1
- data/LICENSE.txt +21 -0
- data/README.adoc +150 -0
- data/Rakefile +119 -0
- data/bin/rspec +1 -0
- data/bin/setup +18 -1
- data/ci/install_botan.sh +28 -0
- data/ci/install_json_c.sh +32 -0
- data/ci/install_rnp.sh +31 -0
- data/docs/GPGMEAdapter.adoc +68 -0
- data/docs/RNPAdapter.adoc +45 -0
- data/enmail.gemspec +21 -8
- data/lib/enmail.rb +25 -4
- data/lib/enmail/adapters/base.rb +14 -0
- data/lib/enmail/adapters/gpgme.rb +81 -0
- data/lib/enmail/adapters/gpgme_requirements.rb +3 -0
- data/lib/enmail/adapters/rnp.rb +109 -0
- data/lib/enmail/adapters/rnp_requirements.rb +3 -0
- data/lib/enmail/dependency_constraints.rb +9 -0
- data/lib/enmail/extensions/message_transport_encoding_restrictions.rb +20 -0
- data/lib/enmail/helpers/message_manipulation.rb +73 -0
- data/lib/enmail/helpers/rfc1847.rb +103 -0
- data/lib/enmail/helpers/rfc3156.rb +60 -0
- data/lib/enmail/version.rb +4 -1
- metadata +99 -24
- data/README.md +0 -115
- data/lib/enmail/certificate_finder.rb +0 -75
- data/lib/enmail/config.rb +0 -21
- data/lib/enmail/configuration.rb +0 -80
- data/lib/enmail/enmailable.rb +0 -43
- data/lib/enmail/key.rb +0 -53
- data/lib/enmail/mail_ext/message.rb +0 -18
- data/lib/mail/secure/mail_interceptors/pgp.rb +0 -53
- data/lib/mail/secure/models/key.rb +0 -5
- data/lib/mail/secure/pgp_mailable.rb +0 -107
@@ -1,107 +0,0 @@
|
|
1
|
-
module Mail::Secure
|
2
|
-
|
3
|
-
# Include this in your mailer class
|
4
|
-
module PGPMailable
|
5
|
-
|
6
|
-
require 'active_support/concern'
|
7
|
-
extend ActiveSupport::Concern
|
8
|
-
|
9
|
-
module InstanceMethods
|
10
|
-
|
11
|
-
# TODO: extract this out for use on a lower level - i.e. not specific to
|
12
|
-
# Rails / ActionMailer.
|
13
|
-
# Boolean: true iff we want to enable signing of emails, false iff we
|
14
|
-
# want to disable it.
|
15
|
-
def sign_emails?
|
16
|
-
# TODO: fetch from config
|
17
|
-
end
|
18
|
-
|
19
|
-
# TODO: extract this out for use on a lower level - i.e. not specific to
|
20
|
-
# Rails / ActionMailer.
|
21
|
-
# Has the following properties:
|
22
|
-
# - email
|
23
|
-
# - fingerprint
|
24
|
-
# - user ids
|
25
|
-
# - key body
|
26
|
-
def active_key
|
27
|
-
# TODO: fetch from config
|
28
|
-
end
|
29
|
-
|
30
|
-
# TODO: extract this out for use on a lower level - i.e. not specific to
|
31
|
-
# Rails / ActionMailer.
|
32
|
-
# Implement this!
|
33
|
-
def key_url
|
34
|
-
'IMPLEMENT THIS'
|
35
|
-
end
|
36
|
-
|
37
|
-
# TODO: extract this out for use on a lower level - i.e. not specific to
|
38
|
-
# Rails / ActionMailer.
|
39
|
-
def add_pgp_headers(headers)
|
40
|
-
return headers unless sign_emails? && active_key
|
41
|
-
|
42
|
-
key_fingerprint = active_key.fingerprint
|
43
|
-
|
44
|
-
headers.merge(
|
45
|
-
gpg: {
|
46
|
-
sign: true,
|
47
|
-
sign_as: active_key.email,
|
48
|
-
},
|
49
|
-
|
50
|
-
# https://www.ietf.org/archive/id/draft-josefsson-openpgp-mailnews-header-07.txt
|
51
|
-
'X-PGP-Key': key_url,
|
52
|
-
OpenPGP: {
|
53
|
-
url: key_url,
|
54
|
-
id: key_fingerprint,
|
55
|
-
}.map{|k, v| "#{k}=#{v};"}.join(" ")
|
56
|
-
)
|
57
|
-
|
58
|
-
rescue StandardError => e
|
59
|
-
if Rails.env.test?
|
60
|
-
raise e
|
61
|
-
end
|
62
|
-
Rails.logger.error "[PGPMailable] Error unable to sign emails: #{e.message} #{e.backtrace}"
|
63
|
-
headers
|
64
|
-
end
|
65
|
-
|
66
|
-
# NOTE: This can remain in PGPMailable because it's specific to
|
67
|
-
# ActionMailer.
|
68
|
-
def mail headers={}, &block
|
69
|
-
# puts "what are headers? #{add_pgp_headers(headers).pretty_inspect}"
|
70
|
-
super(add_pgp_headers(headers), &block).tap do |m|
|
71
|
-
# puts m.to_s
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
end
|
76
|
-
|
77
|
-
included do
|
78
|
-
|
79
|
-
def self.apply(base=self)
|
80
|
-
|
81
|
-
# You can't use .prepend on ActionMailer::Base, oh no you can't!
|
82
|
-
add_to = case base
|
83
|
-
when ActionMailer::Base
|
84
|
-
:include
|
85
|
-
else :prepend
|
86
|
-
end
|
87
|
-
|
88
|
-
unless base < InstanceMethods
|
89
|
-
self.send add_to, Mail::Gpg::Rails::ActionMailerPatch::InstanceMethods
|
90
|
-
self.send add_to, InstanceMethods
|
91
|
-
# self.singleton_class.send add_to, Mail::Gpg::Rails::ActionMailerPatch::ClassMethods
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
apply
|
96
|
-
|
97
|
-
# This would override the original .extended
|
98
|
-
# def self.extended(base)
|
99
|
-
# puts " sooo #{self}.extended #{base}"
|
100
|
-
# apply base
|
101
|
-
# super
|
102
|
-
# end
|
103
|
-
|
104
|
-
end
|
105
|
-
|
106
|
-
end
|
107
|
-
end
|