forked from freedomofpress/redmine_openpgp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
init.rb
45 lines (40 loc) · 1.27 KB
/
init.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#!/bin/env ruby
# encoding: utf-8
require 'gpgme'
require 'mail-gpg'
Redmine::Plugin.register :openpgp do
name 'OpenPGP'
author 'Alexander Blum'
description 'Email encryption with the OpenPGP standard'
version '1.0.1'
author_url 'mailto:[email protected]'
url 'https://github.com/C3S/redmine_openpgp'
settings(:default => {
'signature_needed' => false,
'encryption_scope' => 'project',
'unencrypted_mails' => 'filtered',
'encrypted_html' => false,
'filtered_mail_footer' => ''
}, :partial => 'settings/openpgp')
project_module :openpgp do
permission :block_email, { :openpgp => :show }
end
menu :account_menu, :pgpkeys, { :controller => 'pgpkeys', :action => 'index' },
:caption => 'PGP', :after => :my_account,
:if => Proc.new { User.current.logged? }
end
# encrypt outgoing mails
ActionDispatch::Callbacks.to_prepare do
require_dependency 'mailer'
Mailer.send(:include, EncryptMails)
end
# decrypt received mails
ActionDispatch::Callbacks.to_prepare do
require_dependency 'mail_handler'
MailHandler.send(:include, DecryptMails)
end
# allow unencrypted+unsigned mails based on per-project setting
ActionDispatch::Callbacks.to_prepare do
require_dependency 'mail_handler'
MailHandler.send(:include, MailHandlerPatch)
end