on master help sign in
Merge pull request #2411 from dalf/update-secret-key-check

Update secret key check

commit5fb9a5c7c10252b21a23fe66e1625ed9f8691b4a authorAlexandre Flament <alex@al-f.net> dateSun 27 Dec 2020, 18:04 (6 years ago) parent5840499568b946
7 files changed+27−14
docs/admin/engines.rst+1−1 docs/admin/plugins.rst+1−1 docs/conf.py+8−2 docs/dev/reST.rst+11−5 searx/__init__.py−4 searx/webapp.py+5 utils/standalone_searx.py+1−1
docs/admin/engines.rst+1−1
@@ -46,7 +46,7 @@ Show errors **DE**
4646
4747.. _configured engines:
4848
49−.. jinja:: webapp
49+.. jinja:: searx
5050
5151 .. flat-table:: Engines configured at built time (defaults)
5252 :header-rows: 1
docs/admin/plugins.rst+1−1
@@ -14,7 +14,7 @@ Configuration defaults (at built time):
1414
1515.. _configured plugins:
1616
17−.. jinja:: webapp
17+.. jinja:: searx
1818
1919 .. flat-table:: Plugins configured at built time (defaults)
2020 :header-rows: 1
docs/conf.py+8−2
@@ -27,9 +27,15 @@ numfig = True
2727
2828exclude_patterns = ['build-templates/*.rst']
2929
30−from searx import webapp
30+import searx.search
31+import searx.engines
32+import searx.plugins
33+searx.search.initialize()
3134jinja_contexts = {
32− 'webapp': dict(**webapp.__dict__),
35+ 'searx': {
36+ 'engines': searx.engines.engines,
37+ 'plugins': searx.plugins.plugins
38+ },
3339}
3440
3541# usage:: lorem :patch:`f373169` ipsum
docs/dev/reST.rst+11−5
@@ -1289,15 +1289,21 @@ build chapter: :ref:`engines generic`. Below the jinja directive from the
12891289 :language: reST
12901290 :start-after: .. _configured engines:
12911291
1292−The context for the template is selected in the line ``.. jinja:: webapp``. In
1293−sphinx's build configuration (:origin:`docs/conf.py`) the ``webapp`` context
1294−points to the name space of the python module: ``webapp``.
1292+The context for the template is selected in the line ``.. jinja:: searx``. In
1293+sphinx's build configuration (:origin:`docs/conf.py`) the ``searx`` context
1294+contains the ``engines`` and ``plugins``.
12951295
12961296.. code:: py
12971297
1298− from searx import webapp
1298+ import searx.search
1299+ import searx.engines
1300+ import searx.plugins
1301+ searx.search.initialize()
12991302 jinja_contexts = {
1300− 'webapp': dict(**webapp.__dict__)
1303+ 'searx': {
1304+ 'engines': searx.engines.engines,
1305+ 'plugins': searx.plugins.plugins
1306+ },
13011307 }
13021308
13031309
searx/__init__.py−4
@@ -60,7 +60,3 @@ if 'SEARX_SECRET' in environ:
6060 settings['server']['secret_key'] = environ['SEARX_SECRET']
6161if 'SEARX_BIND_ADDRESS' in environ:
6262 settings['server']['bind_address'] = environ['SEARX_BIND_ADDRESS']
63−
64−if not searx_debug and settings['server']['secret_key'] == 'ultrasecretkey':
65− logger.error('server.secret_key is not changed. Please use something else instead of ultrasecretkey.')
66− exit(1)
searx/webapp.py+5
@@ -86,6 +86,11 @@ from searx.metrology.error_recorder import errors_per_engines
8686from werkzeug.serving import WSGIRequestHandler
8787WSGIRequestHandler.protocol_version = "HTTP/{}".format(settings['server'].get('http_protocol_version', '1.0'))
8888
89+# check secret_key
90+if not searx_debug and settings['server']['secret_key'] == 'ultrasecretkey':
91+ logger.error('server.secret_key is not changed. Please use something else instead of ultrasecretkey.')
92+ exit(1)
93+
8994# about static
9095static_path = get_resources_directory(searx_dir, 'static', settings['ui']['static_path'])
9196logger.debug('static directory is %s', static_path)
utils/standalone_searx.py+1−1
@@ -15,7 +15,7 @@ Example to use this script:
1515
1616.. code:: bash
1717
18− $ SEARX_DEBUG=1 python3 utils/standalone_searx.py rain
18+ $ python3 utils/standalone_searx.py rain
1919
2020Example to run it from python:
2121