DSatishchandra commited on
Commit
d3245ed
·
verified ·
1 Parent(s): 90cbcf2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -7
app.py CHANGED
@@ -1,5 +1,6 @@
1
  from flask import Flask, render_template, request, jsonify, redirect, url_for, session
2
- from flask.sessions import SecureCookieSessionInterface
 
3
  from salesforce import get_salesforce_connection
4
  import os
5
 
@@ -15,13 +16,14 @@ print("Salesforce connection established.")
15
  # Set the secret key to handle sessions securely
16
  app.secret_key = os.getenv("SECRET_KEY", "sSSjyhInIsUohKpG8sHzty2q") # Replace with a secure key
17
 
18
- app.config["SESSION_COOKIE_PATH"] = "/" # Available across all routes
19
- app.config["SESSION_COOKIE_DOMAIN"] = None # Let the browser determine the domain
20
- app.config["SESSION_COOKIE_SECURE"] = False # Set to True if HTTPS
21
- app.config["SESSION_COOKIE_HTTPONLY"] = True # Prevent JavaScript access
22
- app.config["SESSION_PERMANENT"] = False # Do not use permanent sessions
23
 
24
- Session(app)
 
 
25
 
26
  # Ensure secure session handling for environments like Hugging Face
27
  app.session_interface = SecureCookieSessionInterface()
 
1
  from flask import Flask, render_template, request, jsonify, redirect, url_for, session
2
+ from flask_session import Session # Import the Session class
3
+ import random
4
  from salesforce import get_salesforce_connection
5
  import os
6
 
 
16
  # Set the secret key to handle sessions securely
17
  app.secret_key = os.getenv("SECRET_KEY", "sSSjyhInIsUohKpG8sHzty2q") # Replace with a secure key
18
 
19
+ # Configure the session type
20
+ app.config["SESSION_TYPE"] = "filesystem" # Use filesystem for session storage
21
+ app.config["SESSION_COOKIE_SAMESITE"] = "None" # Allow cross-site cookies
22
+ app.config["SESSION_COOKIE_SECURE"] = True # Secure cookies over HTTPS
 
23
 
24
+ # Initialize the session
25
+ Session(app) # Correctly initialize the Session object
26
+ print("Session interface configured.")
27
 
28
  # Ensure secure session handling for environments like Hugging Face
29
  app.session_interface = SecureCookieSessionInterface()