Skip to content

Commit c0b725c

Browse files
committed
Give better error message when invalid data is passed to cauth in d param
Int he sample cauth provider for django, the incoming data in the 'd' parameter is supposed to be the three parts required to do a SIV decryption of it. But if somebody is sitting on an old link or ends up going through history or something like that it can end up with just two parameters since that's what the old version of the plugin uses. Instead of crashing on that, give an error message so the user can just retry.
1 parent e54c328 commit c0b725c

File tree

1 file changed

+4
-1
lines changed
  • tools/communityauth/sample/django

1 file changed

+4
-1
lines changed

tools/communityauth/sample/django/auth.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,10 @@ def auth_receive(request):
211211
# Finally, check of we have a data package that tells us where to
212212
# redirect the user.
213213
if 'd' in data:
214-
(nonces, datas, tags) = data['d'][0].split('$')
214+
splitdata = data['d'][0].split('$')
215+
if len(splitdata) != 3:
216+
return HttpResponse("Invalid login pass-through data received, likely because of an old link. Please try again.")
217+
(nonces, datas, tags) = splitdata
215218
decryptor = AES.new(
216219
SHA256.new(settings.SECRET_KEY.encode('ascii')).digest()[:32],
217220
AES.MODE_SIV,

0 commit comments

Comments
 (0)