Skip to content
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
6 changes: 1 addition & 5 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
os.environ["OAUTHLIB_RELAX_TOKEN_SCOPE"] = "1"

from flask import Flask, Response, jsonify, redirect, render_template, request, session
from flask_session import Session
from google.oauth2.credentials import Credentials
from google_auth_oauthlib.flow import Flow
from googleapiclient.discovery import build
Expand All @@ -34,16 +33,14 @@
app = Flask(__name__)
app.wsgi_app = ProxyFix(app.wsgi_app, x_for=1, x_proto=1, x_host=1, x_port=1)

# Session configuration
# Session configuration — uses Flask's built-in signed-cookie sessions (no filesystem required)
secret_key = os.environ.get("FLASK_SECRET_KEY")
if not secret_key:
if os.environ.get("FLASK_ENV") == "development":
secret_key = "dev-secret-key-for-local-development-only"
else:
raise ValueError("FLASK_SECRET_KEY environment variable must be set in production")
app.config["SECRET_KEY"] = secret_key
app.config["SESSION_TYPE"] = "filesystem"
app.config["SESSION_FILE_DIR"] = "/data/flask_session"
# Only require HTTPS cookies in production (localhost uses HTTP)
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

medium

The removal of SESSION_TYPE and SESSION_FILE_DIR is correct for the switch to cookie-based sessions. However, the test configuration in tests/conftest.py (lines 39-40) still contains these keys and attempts to set up a filesystem session directory. This will lead to dead configuration and potential confusion in the test suite. Please update the app fixture in tests/conftest.py to remove the obsolete session configuration.

References
  1. Maintainability: Adherence to language idioms and best practices, including removing dead configuration. (link)

# Can be overridden via SESSION_COOKIE_SECURE env var (set to "false" for dev)
session_cookie_secure = os.environ.get("SESSION_COOKIE_SECURE", "").lower()
Expand All @@ -56,7 +53,6 @@
app.config["SESSION_COOKIE_SECURE"] = os.environ.get("FLASK_ENV") != "development"
app.config["SESSION_COOKIE_HTTPONLY"] = True # Prevent JavaScript access
app.config["SESSION_COOKIE_SAMESITE"] = "Lax" # CSRF protection
Session(app)


@app.errorhandler(Exception)
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
flask>=3.0
flask-session>=0.5
google-auth>=2.0
google-auth-oauthlib>=1.0
google-api-python-client>=2.0
Expand Down
Loading