diff options
author | Markus Heiser <markus.heiser@darmarit.de> | 2023-04-19 18:59:23 +0200 |
---|---|---|
committer | Markus Heiser <markus.heiser@darmarit.de> | 2023-05-29 14:54:56 +0200 |
commit | 5226044c13817688a5ca3461743844dca4ed3d2b (patch) | |
tree | 562158cf27ac7819dd38a0979ee45557d7fd344a /searx/webapp.py | |
parent | dba569462d0e9c4dbd77a54bb42ef5c3b1916142 (diff) | |
download | searxng-5226044c13817688a5ca3461743844dca4ed3d2b.tar.gz searxng-5226044c13817688a5ca3461743844dca4ed3d2b.zip |
[mod] limiter: add random token to the limiter URL
By adding a random component in the limiter URL a bot can no longer send a ping
by request a static URL.
Related: https://github.com/searxng/searxng/pull/2357#issuecomment-1518525094
Signed-off-by: Markus Heiser <markus.heiser@darmarit.de>
Diffstat (limited to 'searx/webapp.py')
-rwxr-xr-x | searx/webapp.py | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/searx/webapp.py b/searx/webapp.py index 67265e542..815bfcabd 100755 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -416,6 +416,7 @@ def render(template_name: str, **kwargs): kwargs['endpoint'] = 'results' if 'q' in kwargs else request.endpoint kwargs['cookies'] = request.cookies kwargs['errors'] = request.errors + kwargs['limiter_token'] = limiter.get_token() # values from the preferences kwargs['preferences'] = request.preferences @@ -642,9 +643,10 @@ def health(): return Response('OK', mimetype='text/plain') -@app.route('/limiter.css', methods=['GET', 'POST']) -def limiter_css(): - limiter.ping() +@app.route('/limiter<token>.css', methods=['GET', 'POST']) +def limiter_css(token=None): + if limiter.token_is_valid(token): + limiter.ping() return Response('', mimetype='text/css') |