Simplify cookie domain/path settings, per discussion. Instead of trying to be smart, just let the user specify them in the config, e.g.

COOKIE_DEFAULT_DOMAIN = None
SESSION_COOKIE_DOMAIN = None
This commit is contained in:
Khushboo Vashi 2018-03-23 10:14:02 +00:00 committed by Dave Page
parent 1f84285d99
commit 413709fc78
4 changed files with 8 additions and 13 deletions

View File

@ -252,7 +252,6 @@ SESSION_DB_PATH = os.path.join(DATA_DIR, 'sessions')
SESSION_COOKIE_NAME = 'pga4_session'
SESSION_COOKIE_DOMAIN = DEFAULT_SERVER
##########################################################################
# Mail server settings
##########################################################################
@ -361,7 +360,8 @@ SHOW_GRAVATAR_IMAGE = True
# Set cookie path
##########################################################################
COOKIE_DEFAULT_PATH = '/'
COOKIE_DEFAULT_DOMAIN = DEFAULT_SERVER
COOKIE_DEFAULT_DOMAIN = None
SESSION_COOKIE_DOMAIN = None
##########################################################################
# Local config settings

View File

@ -541,14 +541,6 @@ def create_app(app_name=None):
app.logger.info('Registering blueprint module: %s' % module)
app.register_blueprint(module)
#########################################################################
# Set cookie path
#########################################################################
@app.before_first_request
def before_first_request():
from pgadmin.utils.paths import get_cookie_path
config.COOKIE_DEFAULT_PATH = get_cookie_path()
##########################################################################
# Handle the desktop login
##########################################################################
@ -586,7 +578,8 @@ def create_app(app_name=None):
def after_request(response):
if 'key' in request.args:
domain = dict()
if config.COOKIE_DEFAULT_DOMAIN != 'localhost':
if config.COOKIE_DEFAULT_DOMAIN and \
config.COOKIE_DEFAULT_DOMAIN != 'localhost':
domain['domain'] = config.COOKIE_DEFAULT_DOMAIN
response.set_cookie('PGADMIN_KEY', value=request.args['key'],
path=config.COOKIE_DEFAULT_PATH,

View File

@ -799,7 +799,8 @@ def index():
language = user_languages.get() or 'en'
domain = dict()
if config.COOKIE_DEFAULT_DOMAIN != 'localhost':
if config.COOKIE_DEFAULT_DOMAIN and\
config.COOKIE_DEFAULT_DOMAIN != 'localhost':
domain['domain'] = config.COOKIE_DEFAULT_DOMAIN
response.set_cookie("PGADMIN_LANGUAGE", value=language,

View File

@ -200,7 +200,8 @@ def save(pid):
language = user_languages.get() or language
domain = dict()
if config.COOKIE_DEFAULT_DOMAIN != 'localhost':
if config.COOKIE_DEFAULT_DOMAIN and\
config.COOKIE_DEFAULT_DOMAIN != 'localhost':
domain['domain'] = config.COOKIE_DEFAULT_DOMAIN
setattr(session, 'PGADMIN_LANGUAGE', language)