mirror of https://github.com/CIRCL/AIL-framework
fix: [UI caching] fix: #373 avoid screenshot caching
parent
dfd1128daa
commit
6dcecd6ba6
|
@ -178,7 +178,8 @@ def add_header(response):
|
||||||
and also to cache the rendered page for 10 minutes.
|
and also to cache the rendered page for 10 minutes.
|
||||||
"""
|
"""
|
||||||
response.headers['X-UA-Compatible'] = 'IE=Edge,chrome=1'
|
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
|
return response
|
||||||
|
|
||||||
# @app.route('/test', methods=['GET'])
|
# @app.route('/test', methods=['GET'])
|
||||||
|
|
|
@ -10,7 +10,7 @@ import configparser
|
||||||
from functools import wraps
|
from functools import wraps
|
||||||
from flask_login import LoginManager, current_user, login_user, logout_user, login_required
|
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 = LoginManager()
|
||||||
login_manager.login_view = 'role'
|
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 = r'^(?=(.*\d){2})(?=.*[a-z])(?=.*[A-Z]).{10,100}$'
|
||||||
regex_password = re.compile(regex_password)
|
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 ##################
|
############### CHECK ROLE ACCESS ##################
|
||||||
###############################################################
|
###############################################################
|
||||||
|
|
|
@ -10,7 +10,7 @@ import os
|
||||||
import flask
|
import flask
|
||||||
from flask import Flask, render_template, jsonify, request, Blueprint, make_response, Response, send_from_directory, redirect, url_for
|
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
|
from flask_login import login_required
|
||||||
|
|
||||||
import difflib
|
import difflib
|
||||||
|
@ -446,6 +446,7 @@ def showDiff():
|
||||||
@showsavedpastes.route('/screenshot/<path:filename>')
|
@showsavedpastes.route('/screenshot/<path:filename>')
|
||||||
@login_required
|
@login_required
|
||||||
@login_analyst
|
@login_analyst
|
||||||
|
@no_cache
|
||||||
def screenshot(filename):
|
def screenshot(filename):
|
||||||
return send_from_directory(SCREENSHOT_FOLDER, filename+'.png', as_attachment=True)
|
return send_from_directory(SCREENSHOT_FOLDER, filename+'.png', as_attachment=True)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue