C3S / redmine_openpgp

Redmine plugin for email encryption with the OpenPGP standard
GNU General Public License v3.0
19 stars 10 forks source link

Allow unsigned & unencrypted incoming mails based on per-project activation setting #14

Open ageis opened 8 years ago

ageis commented 8 years ago

Currently if "Valid signatures only" is enabled, all unencrypted+unsigned mail will be rejected, regardless of the per-project activation setting. If you're validating signatures, you cannot have a project which is intended to receive unencrypted email (by leaving the OpenPGP module disabled on it) at the same time.

The decryption method should ideally be aware of the whether the OpenPGP module is enabled on the target project of the email.

Because of the odd order of operations and my lack of aptitude with Ruby on Rails, I'm not sure whether it could be implemented without modifying core. One issue is that the target_project is apparently not available at the time of MailHandler's receive operation, only afterward. So we need to patch the MailHandler to decrypt the email, check the signature, get the target project, then check that project's per-project activation setting, and finally determine whether to accept or reject the email.

ageis commented 8 years ago

After studying mail_handler.rb in more detail, here's one approach to adding this feature: https://github.com/ageis/redmine_openpgp/commit/362ddaf9314cafc4479aa4b0cf418be720674e2c

Notes: The target_project seems to become accessible after running dispatch(), which then calls dispatch_to_default(), which simply calls receive_issue(). I'm using a global variable $invalid to store whether emails are valid between running the decryption module and checking the per-project settings in the new module. Don't know if there's a better way to do this.

timegrid commented 7 years ago

I see. I'll take a look into your solution as soon as I catch up with your fork.