Skip to content

Commit d904c02

Browse files
committed
Merged in [19393] from krathnayake@ietf.org:
Fixes API authentication issue. - Legacy-Id: 19395 Note: SVN reference [19393] has been migrated to Git commit 90297bc
2 parents cb5c948 + 90297bc commit d904c02

2 files changed

Lines changed: 3 additions & 1 deletion

File tree

ietf/ietfauth/tests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ def test_apikey_errors(self):
656656
unauthorized_url = urlreverse('ietf.api.views.author_tools')
657657
invalidated_apikey = PersonalApiKey.objects.create(
658658
endpoint=unauthorized_url, person=person, valid=False)
659-
r = self.client.post(unauthorized_url, {'apikey': invalidated_apikey})
659+
r = self.client.post(unauthorized_url, {'apikey': invalidated_apikey.hash()})
660660
self.assertContains(r, 'Invalid apikey', status_code=403)
661661

662662
# too long since regular login

ietf/person/models.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,8 @@ def validate_key(cls, s):
394394
if not k.exists():
395395
return None
396396
k = k.first()
397+
if not k.valid:
398+
return None
397399
check = hashlib.sha256()
398400
for v in (str(id), str(k.person.id), k.created.isoformat(), k.endpoint, str(k.valid), salt, settings.SECRET_KEY):
399401
v = smart_bytes(v)

0 commit comments

Comments
 (0)