Convert times to int

Make iat_time, exp_time, auth_time an integer, not a float. The spec
does not explicitly forbit float times, but some clients don't accept
this (mod_auth_openidc), and `timetuple()` has second precision anyway
so we don't loose any information.
This commit is contained in:
Sjoerd Langkemper 2015-07-15 12:06:02 +02:00
parent 1faeb6d5ab
commit 00f30dabbf

View file

@ -25,11 +25,11 @@ def create_id_token(user, aud, nonce=None):
now = timezone.now() now = timezone.now()
# Convert datetimes into timestamps. # Convert datetimes into timestamps.
iat_time = time.mktime(now.timetuple()) iat_time = int(time.mktime(now.timetuple()))
exp_time = time.mktime((now + timedelta(seconds=expires_in)).timetuple()) exp_time = int(time.mktime((now + timedelta(seconds=expires_in)).timetuple()))
user_auth_time = user.last_login or user.date_joined user_auth_time = user.last_login or user.date_joined
auth_time = time.mktime(user_auth_time.timetuple()) auth_time = int(time.mktime(user_auth_time.timetuple()))
dic = { dic = {
'iss': get_issuer(), 'iss': get_issuer(),