diff --git a/var/www/Flask_server.py b/var/www/Flask_server.py index 3d1b524e..4575ddb9 100755 --- a/var/www/Flask_server.py +++ b/var/www/Flask_server.py @@ -178,7 +178,8 @@ def add_header(response): and also to cache the rendered page for 10 minutes. """ response.headers['X-UA-Compatible'] = 'IE=Edge,chrome=1' - response.headers['Cache-Control'] = 'public, max-age=0' + if 'Cache-Control' not in response.headers: + response.headers['Cache-Control'] = 'private, max-age=0' return response # @app.route('/test', methods=['GET']) diff --git a/var/www/modules/Role_Manager.py b/var/www/modules/Role_Manager.py index dc4e7ce1..c4c2ad92 100644 --- a/var/www/modules/Role_Manager.py +++ b/var/www/modules/Role_Manager.py @@ -10,7 +10,7 @@ import configparser from functools import wraps from flask_login import LoginManager, current_user, login_user, logout_user, login_required -from flask import request, current_app +from flask import request, make_response, current_app login_manager = LoginManager() login_manager.login_view = 'role' @@ -36,6 +36,21 @@ default_passwd_file = os.path.join(os.environ['AIL_HOME'], 'DEFAULT_PASSWORD') regex_password = r'^(?=(.*\d){2})(?=.*[a-z])(?=.*[A-Z]).{10,100}$' regex_password = re.compile(regex_password) +############################################################### +############### CHECK ROLE ACCESS ################## +############################################################### +def no_cache(func): + @wraps(func) + def decorated_view(*args, **kwargs): + resp = make_response(func(*args, **kwargs)) + resp.headers['Cache-Control'] = 'no-cache, no-store, must-revalidate' + resp.headers['Pragma'] = 'no-cache' + return resp + return decorated_view +############################################################### +############################################################### +############################################################### + ############################################################### ############### CHECK ROLE ACCESS ################## ############################################################### diff --git a/var/www/modules/showpaste/Flask_showpaste.py b/var/www/modules/showpaste/Flask_showpaste.py index fb990bbf..10519d53 100644 --- a/var/www/modules/showpaste/Flask_showpaste.py +++ b/var/www/modules/showpaste/Flask_showpaste.py @@ -10,7 +10,7 @@ import os import flask from flask import Flask, render_template, jsonify, request, Blueprint, make_response, Response, send_from_directory, redirect, url_for -from Role_Manager import login_admin, login_analyst +from Role_Manager import login_admin, login_analyst, no_cache from flask_login import login_required import difflib @@ -446,6 +446,7 @@ def showDiff(): @showsavedpastes.route('/screenshot/') @login_required @login_analyst +@no_cache def screenshot(filename): return send_from_directory(SCREENSHOT_FOLDER, filename+'.png', as_attachment=True)