Specify algorithms for webpush jwt verification (#12378)

pull/12400/head
Paulus Schoutsen 2018-02-13 14:23:34 -08:00 committed by Fabian Affolter
parent 5995c2f313
commit f0231c1f29
1 changed files with 2 additions and 2 deletions

View File

@ -255,12 +255,12 @@ class HTML5PushCallbackView(HomeAssistantView):
# 2a. If decode is successful, return the payload.
# 2b. If decode is unsuccessful, return a 401.
target_check = jwt.decode(token, options={'verify_signature': False})
target_check = jwt.decode(token, verify=False)
if target_check[ATTR_TARGET] in self.registrations:
possible_target = self.registrations[target_check[ATTR_TARGET]]
key = possible_target[ATTR_SUBSCRIPTION][ATTR_KEYS][ATTR_AUTH]
try:
return jwt.decode(token, key)
return jwt.decode(token, key, algorithms=["ES256", "HS256"])
except jwt.exceptions.DecodeError:
pass