Cleanup
This commit is contained in:
parent
a17ca89819
commit
af434188a2
1 changed files with 32 additions and 34 deletions
|
@ -3681,40 +3681,38 @@ class RequestHandler(BaseHTTPRequestHandler):
|
|||
req = urlparse(self.path)
|
||||
if SESAME or TOTP:
|
||||
chunk = req.path.split("/")[-1]
|
||||
if SESAME:
|
||||
if chunk == SESAME:
|
||||
if self.client_address[0] not in ALLOWED_NETWORKS:
|
||||
ALLOWED_NETWORKS.append(self.client_address[0])
|
||||
if self.client_address[0] in BANNED_IPS:
|
||||
BANNED_IPS.remove(self.client_address[0])
|
||||
url = req.path[:req.path.rfind(chunk)]
|
||||
self.send_response(302)
|
||||
self.send_header('Location', url)
|
||||
self.end_headers()
|
||||
data = {
|
||||
"title": "HASS Configurator - SESAME access",
|
||||
"message": "Your SESAME token has been used to whitelist " \
|
||||
"the IP address %s." % self.client_address[0]
|
||||
}
|
||||
notify(**data)
|
||||
return
|
||||
if TOTP:
|
||||
if TOTP.verify(chunk):
|
||||
if self.client_address[0] not in ALLOWED_NETWORKS:
|
||||
ALLOWED_NETWORKS.append(self.client_address[0])
|
||||
if self.client_address[0] in BANNED_IPS:
|
||||
BANNED_IPS.remove(self.client_address[0])
|
||||
url = req.path[:req.path.rfind(chunk)]
|
||||
self.send_response(302)
|
||||
self.send_header('Location', url)
|
||||
self.end_headers()
|
||||
data = {
|
||||
"title": "HASS Configurator - SESAME access",
|
||||
"message": "Your SESAME token has been used to whitelist " \
|
||||
"the IP address %s." % self.client_address[0]
|
||||
}
|
||||
notify(**data)
|
||||
return
|
||||
if SESAME and chunk == SESAME:
|
||||
if self.client_address[0] not in ALLOWED_NETWORKS:
|
||||
ALLOWED_NETWORKS.append(self.client_address[0])
|
||||
if self.client_address[0] in BANNED_IPS:
|
||||
BANNED_IPS.remove(self.client_address[0])
|
||||
url = req.path[:req.path.rfind(chunk)]
|
||||
self.send_response(302)
|
||||
self.send_header('Location', url)
|
||||
self.end_headers()
|
||||
data = {
|
||||
"title": "HASS Configurator - SESAME access",
|
||||
"message": "Your SESAME token has been used to whitelist " \
|
||||
"the IP address %s." % self.client_address[0]
|
||||
}
|
||||
notify(**data)
|
||||
return
|
||||
if TOTP and TOTP.verify(chunk):
|
||||
if self.client_address[0] not in ALLOWED_NETWORKS:
|
||||
ALLOWED_NETWORKS.append(self.client_address[0])
|
||||
if self.client_address[0] in BANNED_IPS:
|
||||
BANNED_IPS.remove(self.client_address[0])
|
||||
url = req.path[:req.path.rfind(chunk)]
|
||||
self.send_response(302)
|
||||
self.send_header('Location', url)
|
||||
self.end_headers()
|
||||
data = {
|
||||
"title": "HASS Configurator - SESAME access",
|
||||
"message": "Your SESAME token has been used to whitelist " \
|
||||
"the IP address %s." % self.client_address[0]
|
||||
}
|
||||
notify(**data)
|
||||
return
|
||||
if not check_access(self.client_address[0]):
|
||||
self.do_BLOCK()
|
||||
return
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue