Skip to content

Commit

Permalink
Fix: Allow internal link independent of enable log in with proton (#1151
Browse files Browse the repository at this point in the history
)

Co-authored-by: Adrià Casajús <[email protected]>
  • Loading branch information
acasajus and acasajus authored Jul 11, 2022
1 parent 288f086 commit f75bdd0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
5 changes: 4 additions & 1 deletion app/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,10 @@ def sl_getenv(env_var: str, default_factory: Callable = None):
CONNECT_WITH_PROTON = "CONNECT_WITH_PROTON" in os.environ
PROTON_EXTRA_HEADER_NAME = os.environ.get("PROTON_EXTRA_HEADER_NAME")
PROTON_EXTRA_HEADER_VALUE = os.environ.get("PROTON_EXTRA_HEADER_VALUE")
CONNECT_WITH_PROTON_COOKIE_NAME = os.environ.get("CONNECT_WITH_PROTON_COOKIE_NAME")
CONNECT_WITH_PROTON_COOKIE_NAME = os.environ.get(
"CONNECT_WITH_PROTON_COOKIE_NAME", "enable-proton"
)
PROTON_ALLOW_INTERNAL_LINK = "PROTON_ALLOW_INTERNAL_LINK" in os.environ

# in seconds
AVATAR_URL_EXPIRATION = 3600 * 24 * 7 # 1h*24h/d*7d=1week
Expand Down
8 changes: 4 additions & 4 deletions app/internal/integrations.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import arrow
from app.config import CONNECT_WITH_PROTON_COOKIE_NAME, URL
from flask import make_response, redirect, url_for, flash
from flask_login import current_user
from .base import internal_bp
from app import config


@internal_bp.route("/integrations/proton")
Expand All @@ -13,13 +13,13 @@ def set_enable_proton_cookie():
redirect_url = url_for("auth.login")

response = make_response(redirect(redirect_url))
if CONNECT_WITH_PROTON_COOKIE_NAME:
if config.PROTON_ALLOW_INTERNAL_LINK:
flash("You can now connect your Proton and your SimpleLogin account", "success")
response.set_cookie(
CONNECT_WITH_PROTON_COOKIE_NAME,
config.CONNECT_WITH_PROTON_COOKIE_NAME,
value="true",
expires=arrow.now().shift(days=30).datetime,
secure=True if URL.startswith("https") else False,
secure=True if config.URL.startswith("https") else False,
httponly=True,
samesite="Lax",
)
Expand Down

0 comments on commit f75bdd0

Please sign in to comment.