Added a catch for malformed apikey input.
- Legacy-Id: 17769
This commit is contained in:
parent
02804ba163
commit
26e85ce53b
|
@ -351,7 +351,10 @@ class PersonalApiKey(models.Model):
|
||||||
def validate_key(cls, s):
|
def validate_key(cls, s):
|
||||||
import struct, hashlib, base64
|
import struct, hashlib, base64
|
||||||
assert isinstance(s, bytes)
|
assert isinstance(s, bytes)
|
||||||
key = base64.urlsafe_b64decode(s)
|
try:
|
||||||
|
key = base64.urlsafe_b64decode(s)
|
||||||
|
except Exception:
|
||||||
|
return None
|
||||||
id, salt, hash = struct.unpack(KEY_STRUCT, key)
|
id, salt, hash = struct.unpack(KEY_STRUCT, key)
|
||||||
k = cls.objects.filter(id=id)
|
k = cls.objects.filter(id=id)
|
||||||
if not k.exists():
|
if not k.exists():
|
||||||
|
|
Loading…
Reference in a new issue