Merge pull request #171 from SibrenVasse/secure_cookie

Session cookie flags.
This commit is contained in:
Son Nguyen Kim 2020-05-09 18:03:15 +02:00 committed by GitHub
commit 16d8737770
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
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)