Removed no-cache enforcement, minor styling/formatting improvements

main
Ben Busby 2020-06-11 12:14:57 -06:00
parent 4324fcd8f8
commit f86a44b637
4 changed files with 18 additions and 17 deletions

View File

@ -22,7 +22,7 @@ def gen_user_agent(is_mobile):
if is_mobile: if is_mobile:
return MOBILE_UA.format(mozilla, firefox) return MOBILE_UA.format(mozilla, firefox)
else:
return DESKTOP_UA.format(mozilla, linux, firefox) return DESKTOP_UA.format(mozilla, linux, firefox)

View File

@ -1,22 +1,22 @@
from app import app
from app.models.config import Config
from app.request import Request
from app.utils.misc import generate_user_keys, valid_user_session
from app.utils.routing_utils import *
import argparse import argparse
import base64 import base64
from bs4 import BeautifulSoup
from cryptography.fernet import Fernet
from flask import g, jsonify, make_response, request, redirect, render_template, send_file, session
from functools import wraps
import io import io
import json import json
import os import os
import pickle import pickle
import urllib.parse as urlparse import urllib.parse as urlparse
from requests import exceptions
import uuid import uuid
from functools import wraps
import waitress import waitress
from flask import jsonify, make_response, request, redirect, render_template, send_file, session
from requests import exceptions
from app import app
from app.models.config import Config
from app.request import Request
from app.utils.misc import valid_user_session
from app.utils.routing_utils import *
def auth_required(f): def auth_required(f):
@ -87,7 +87,6 @@ def after_request_func(response):
for key in session_list: for key in session_list:
session.pop(key) session.pop(key)
response.headers["Cache-Control"] = "no-cache, no-store, must-revalidate"
return response return response

View File

@ -1,7 +1,7 @@
from cryptography.fernet import Fernet from cryptography.fernet import Fernet
from flask import current_app as app from flask import current_app as app
SESSION_VALS = ['uuid', 'config', 'fernet_keys'] REQUIRED_SESSION_VALUES = ['uuid', 'config', 'fernet_keys']
def generate_user_keys(cookies_disabled=False) -> dict: def generate_user_keys(cookies_disabled=False) -> dict:
@ -17,7 +17,7 @@ def generate_user_keys(cookies_disabled=False) -> dict:
def valid_user_session(session): def valid_user_session(session):
# Generate secret key for user if unavailable # Generate secret key for user if unavailable
for value in SESSION_VALS: for value in REQUIRED_SESSION_VALUES:
if value not in session: if value not in session:
return False return False

View File

@ -32,7 +32,8 @@ class RoutingUtils:
def new_search_query(self) -> str: def new_search_query(self) -> str:
# Generate a new element key each time a new search is performed # Generate a new element key each time a new search is performed
self.session['fernet_keys']['element_key'] = generate_user_keys(cookies_disabled=self.cookies_disabled)['element_key'] self.session['fernet_keys']['element_key'] = generate_user_keys(
cookies_disabled=self.cookies_disabled)['element_key']
q = self.request_params.get('q') q = self.request_params.get('q')
@ -46,7 +47,8 @@ class RoutingUtils:
pass pass
# Reset text key # Reset text key
self.session['fernet_keys']['text_key'] = generate_user_keys(cookies_disabled=self.cookies_disabled)['text_key'] self.session['fernet_keys']['text_key'] = generate_user_keys(
cookies_disabled=self.cookies_disabled)['text_key']
# Format depending on whether or not the query is a "feeling lucky" query # Format depending on whether or not the query is a "feeling lucky" query
self.feeling_lucky = q.startswith('! ') self.feeling_lucky = q.startswith('! ')