Skip to content

Commit

Permalink
Merge pull request #10 from xurble/master
Browse files Browse the repository at this point in the history
Fix bug if client clock is slightly fast
  • Loading branch information
srosro committed May 19, 2015
2 parents ca337a5 + 12621fc commit c38b30b
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion simple_rest/auth/decorators.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,17 @@ def validate_signature(request, secret_key):
return False

# Make sure the signature has not expired
delta = datetime.utcnow() - datetime.utcfromtimestamp(timestamp)
local_time = datetime.utcnow()
remote_time = datetime.utcfromtimestamp(timestamp)


# this stops a bug if the client clock is ever a little ahead of
# the server clock. Makes the window of acceptable time current +/- 5 mins
if local_time > remote_time:
delta = local_time - remote_time
else:
delta = remote_time - local_time

if delta.seconds > 5 * 60: # If the signature is older than 5 minutes, it's invalid
return False

Expand Down

0 comments on commit c38b30b

Please sign in to comment.