Check cookies

This commit is contained in:
Piero Toffanin 2024-09-30 12:42:02 -04:00
parent 930f833c35
commit 46bc256d5b

View file

@ -386,7 +386,7 @@ def create_app(args):
if langcode and langcode in get_available_locale_codes(not args.debug): if langcode and langcode in get_available_locale_codes(not args.debug):
session.update(preferred_lang=langcode) session.update(preferred_lang=langcode)
return render_template( resp = make_response(render_template(
"index.html", "index.html",
gaId=args.ga_id, gaId=args.ga_id,
frontendTimeout=args.frontend_timeout, frontendTimeout=args.frontend_timeout,
@ -398,7 +398,12 @@ def create_app(args):
available_locales=[{'code': l['code'], 'name': _lazy(l['name'])} for l in get_available_locales(not args.debug)], available_locales=[{'code': l['code'], 'name': _lazy(l['name'])} for l in get_available_locales(not args.debug)],
current_locale=get_locale(), current_locale=get_locale(),
alternate_locales=get_alternate_locale_links() alternate_locales=get_alternate_locale_links()
) ))
if args.require_api_key_secret:
resp.set_cookie('r', '1')
return resp
@bp.route("/js/app.js") @bp.route("/js/app.js")
@limiter.exempt @limiter.exempt
@ -411,7 +416,7 @@ def create_app(args):
if args.require_api_key_secret: if args.require_api_key_secret:
bogus_api_secret = secret.get_bogus_secret_b64() bogus_api_secret = secret.get_bogus_secret_b64()
if 'User-Agent' in request.headers: if 'User-Agent' in request.headers and request.cookies.get('r'):
api_secret = secret.get_current_secret_js() api_secret = secret.get_current_secret_js()
else: else:
api_secret = secret.get_bogus_secret_js() api_secret = secret.get_bogus_secret_js()