mirror of
https://github.com/onionshare/onionshare.git
synced 2024-10-01 01:35:40 -04:00
Make separate function for comparing the slug and comparing the shutdown_slug, to prevent 404 errors on the shutdown request
This commit is contained in:
parent
6efc281fbb
commit
7c5d154519
@ -483,7 +483,7 @@ class Web(object):
|
|||||||
"""
|
"""
|
||||||
Stop the flask web server, from the context of an http request.
|
Stop the flask web server, from the context of an http request.
|
||||||
"""
|
"""
|
||||||
self.check_slug_candidate(slug_candidate, self.shutdown_slug)
|
self.check_shutdown_slug_candidate(slug_candidate)
|
||||||
self.force_shutdown()
|
self.force_shutdown()
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
@ -578,14 +578,16 @@ class Web(object):
|
|||||||
log_handler.setLevel(logging.WARNING)
|
log_handler.setLevel(logging.WARNING)
|
||||||
self.app.logger.addHandler(log_handler)
|
self.app.logger.addHandler(log_handler)
|
||||||
|
|
||||||
def check_slug_candidate(self, slug_candidate, slug_compare=None):
|
def check_slug_candidate(self, slug_candidate):
|
||||||
self.common.log('Web', 'check_slug_candidate: slug_candidate={}, slug_compare={}'.format(slug_candidate, slug_compare))
|
self.common.log('Web', 'check_slug_candidate: slug_candidate={}'.format(slug_candidate))
|
||||||
if self.common.settings.get('public_mode'):
|
if self.common.settings.get('public_mode'):
|
||||||
abort(404)
|
abort(404)
|
||||||
else:
|
if not hmac.compare_digest(self.slug, slug_candidate):
|
||||||
if not slug_compare:
|
abort(404)
|
||||||
slug_compare = self.slug
|
|
||||||
if not hmac.compare_digest(slug_compare, slug_candidate):
|
def check_shutdown_slug_candidate(self, slug_candidate):
|
||||||
|
self.common.log('Web', 'check_shutdown_slug_candidate: slug_candidate={}'.format(slug_candidate))
|
||||||
|
if not hmac.compare_digest(self.shutdown_slug, slug_candidate):
|
||||||
abort(404)
|
abort(404)
|
||||||
|
|
||||||
def force_shutdown(self):
|
def force_shutdown(self):
|
||||||
|
Loading…
Reference in New Issue
Block a user