Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent proton mailboxes from enabling pgp encryption #2086

Merged
merged 1 commit into from
Apr 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions app/auth/views/change_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@

from app.auth.base import auth_bp
from app.db import Session
from app.extensions import limiter
from app.log import LOG
from app.models import EmailChange, ResetPasswordCode


@auth_bp.route("/change_email", methods=["GET", "POST"])
@limiter.limit("3/hour")
def change_email():
code = request.args.get("code")

Expand Down
11 changes: 9 additions & 2 deletions app/dashboard/views/mailbox_detail.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,15 @@ def mailbox_detail_route(mailbox_id):

elif request.form.get("form-name") == "toggle-pgp":
if request.form.get("pgp-enabled") == "on":
mailbox.disable_pgp = False
flash(f"PGP is enabled on {mailbox.email}", "success")
if mailbox.is_proton():
mailbox.disable_pgp = True
flash(
"Enabling PGP for a Proton Mail mailbox is redundant and does not add any security benefit",
"info",
)
else:
mailbox.disable_pgp = False
flash(f"PGP is enabled on {mailbox.email}", "info")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"enabled" should be "disabled" here I think

Copy link
Collaborator Author

@acasajus acasajus Apr 12, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this request is to enable pgp. If we want to enable pgp then disabled has to be set to False. We only force it to True if it's a proton mailbox to disable pgp.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The disable_x logic is quite confusing. I event had to edit the previous comment twice to get it right.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah that's true, I think the reason it was called disable_pgp as I want the default value for a new column is false

else:
mailbox.disable_pgp = True
flash(f"PGP is disabled on {mailbox.email}", "info")
Expand Down
Loading