Fix: Allow internal link independent of enable log in with proton (#1151)

Co-authored-by: Adrià Casajús <adria.casajus@proton.ch>
This commit is contained in:
Adrià Casajús 2022-07-11 09:41:20 +02:00 committed by GitHub
parent 288f086a55
commit f75bdd006a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 5 deletions

View File

@ -246,7 +246,10 @@ PROTON_VALIDATE_CERTS = "PROTON_VALIDATE_CERTS" in os.environ
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

View File

@ -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")
@ -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",
)