Set samesite and secure attributes of session cookie. Enable strong session protection.

This commit is contained in:
Sibren Vasse 2020-05-09 14:13:37 +02:00
parent 0e4799030d
commit e7c3a127b8
2 changed files with 4 additions and 0 deletions

View File

@ -5,4 +5,5 @@ from flask_sqlalchemy import SQLAlchemy
db = SQLAlchemy()
login_manager = LoginManager()
login_manager.session_protection = "strong"
migrate = Migrate(db=db)

View File

@ -83,6 +83,9 @@ def create_app() -> Flask:
# to avoid conflict with other cookie
app.config["SESSION_COOKIE_NAME"] = "slapp"
if URL.startswith("https"):
app.config["SESSION_COOKIE_SECURE"] = True
app.config["SESSION_COOKIE_SAMESITE"] = "strict"
init_extensions(app)
register_blueprints(app)