mirror of
https://github.com/pgadmin-org/pgadmin4.git
synced 2025-02-25 18:55:31 -06:00
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:
parent
1f84285d99
commit
413709fc78
@ -252,7 +252,6 @@ SESSION_DB_PATH = os.path.join(DATA_DIR, 'sessions')
|
|||||||
|
|
||||||
SESSION_COOKIE_NAME = 'pga4_session'
|
SESSION_COOKIE_NAME = 'pga4_session'
|
||||||
|
|
||||||
SESSION_COOKIE_DOMAIN = DEFAULT_SERVER
|
|
||||||
##########################################################################
|
##########################################################################
|
||||||
# Mail server settings
|
# Mail server settings
|
||||||
##########################################################################
|
##########################################################################
|
||||||
@ -361,7 +360,8 @@ SHOW_GRAVATAR_IMAGE = True
|
|||||||
# Set cookie path
|
# Set cookie path
|
||||||
##########################################################################
|
##########################################################################
|
||||||
COOKIE_DEFAULT_PATH = '/'
|
COOKIE_DEFAULT_PATH = '/'
|
||||||
COOKIE_DEFAULT_DOMAIN = DEFAULT_SERVER
|
COOKIE_DEFAULT_DOMAIN = None
|
||||||
|
SESSION_COOKIE_DOMAIN = None
|
||||||
|
|
||||||
##########################################################################
|
##########################################################################
|
||||||
# Local config settings
|
# Local config settings
|
||||||
|
@ -541,14 +541,6 @@ def create_app(app_name=None):
|
|||||||
app.logger.info('Registering blueprint module: %s' % module)
|
app.logger.info('Registering blueprint module: %s' % module)
|
||||||
app.register_blueprint(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
|
# Handle the desktop login
|
||||||
##########################################################################
|
##########################################################################
|
||||||
@ -586,7 +578,8 @@ def create_app(app_name=None):
|
|||||||
def after_request(response):
|
def after_request(response):
|
||||||
if 'key' in request.args:
|
if 'key' in request.args:
|
||||||
domain = dict()
|
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
|
domain['domain'] = config.COOKIE_DEFAULT_DOMAIN
|
||||||
response.set_cookie('PGADMIN_KEY', value=request.args['key'],
|
response.set_cookie('PGADMIN_KEY', value=request.args['key'],
|
||||||
path=config.COOKIE_DEFAULT_PATH,
|
path=config.COOKIE_DEFAULT_PATH,
|
||||||
|
@ -799,7 +799,8 @@ def index():
|
|||||||
language = user_languages.get() or 'en'
|
language = user_languages.get() or 'en'
|
||||||
|
|
||||||
domain = dict()
|
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
|
domain['domain'] = config.COOKIE_DEFAULT_DOMAIN
|
||||||
|
|
||||||
response.set_cookie("PGADMIN_LANGUAGE", value=language,
|
response.set_cookie("PGADMIN_LANGUAGE", value=language,
|
||||||
|
@ -200,7 +200,8 @@ def save(pid):
|
|||||||
language = user_languages.get() or language
|
language = user_languages.get() or language
|
||||||
|
|
||||||
domain = dict()
|
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
|
domain['domain'] = config.COOKIE_DEFAULT_DOMAIN
|
||||||
|
|
||||||
setattr(session, 'PGADMIN_LANGUAGE', language)
|
setattr(session, 'PGADMIN_LANGUAGE', language)
|
||||||
|
Loading…
Reference in New Issue
Block a user