Fixes API authentication issue. Commit ready for merge.
- Legacy-Id: 19393
This commit is contained in:
parent
6292e528fd
commit
90297bc2ab
|
@ -656,7 +656,7 @@ class IetfAuthTests(TestCase):
|
|||
unauthorized_url = urlreverse('ietf.api.views.author_tools')
|
||||
invalidated_apikey = PersonalApiKey.objects.create(
|
||||
endpoint=unauthorized_url, person=person, valid=False)
|
||||
r = self.client.post(unauthorized_url, {'apikey': invalidated_apikey})
|
||||
r = self.client.post(unauthorized_url, {'apikey': invalidated_apikey.hash()})
|
||||
self.assertContains(r, 'Invalid apikey', status_code=403)
|
||||
|
||||
# too long since regular login
|
||||
|
|
|
@ -394,6 +394,8 @@ class PersonalApiKey(models.Model):
|
|||
if not k.exists():
|
||||
return None
|
||||
k = k.first()
|
||||
if not k.valid:
|
||||
return None
|
||||
check = hashlib.sha256()
|
||||
for v in (str(id), str(k.person.id), k.created.isoformat(), k.endpoint, str(k.valid), salt, settings.SECRET_KEY):
|
||||
v = smart_bytes(v)
|
||||
|
|
Loading…
Reference in a new issue