providers/oauth2: fix usage of timedelta.seconds

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-06-25 11:55:00 +02:00
parent bb776c2710
commit a3ff7cea23
3 changed files with 14 additions and 10 deletions

View File

@ -474,7 +474,7 @@ class RefreshToken(ExpiringModel, BaseGrantModel):
now = int(time.time()) now = int(time.time())
iat_time = now iat_time = now
exp_time = int( exp_time = int(
now + timedelta_from_string(self.provider.token_validity).seconds now + timedelta_from_string(self.provider.token_validity).total_seconds()
) )
# We use the timestamp of the user's last successful login (EventAction.LOGIN) for auth_time # We use the timestamp of the user's last successful login (EventAction.LOGIN) for auth_time
auth_events = Event.objects.filter( auth_events = Event.objects.filter(

View File

@ -374,9 +374,9 @@ class OAuthFulfillmentStage(StageView):
query_fragment["code"] = code.code query_fragment["code"] = code.code
query_fragment["token_type"] = "bearer" query_fragment["token_type"] = "bearer"
query_fragment["expires_in"] = timedelta_from_string( query_fragment["expires_in"] = int(
self.provider.token_validity timedelta_from_string(self.provider.token_validity).total_seconds()
).seconds )
query_fragment["state"] = self.params.state if self.params.state else "" query_fragment["state"] = self.params.state if self.params.state else ""
return query_fragment return query_fragment

View File

@ -215,9 +215,11 @@ class TokenView(View):
"access_token": refresh_token.access_token, "access_token": refresh_token.access_token,
"refresh_token": refresh_token.refresh_token, "refresh_token": refresh_token.refresh_token,
"token_type": "bearer", "token_type": "bearer",
"expires_in": timedelta_from_string( "expires_in": int(
self.params.provider.token_validity timedelta_from_string(
).seconds, self.params.provider.token_validity
).total_seconds()
),
"id_token": refresh_token.provider.encode(refresh_token.id_token.to_dict()), "id_token": refresh_token.provider.encode(refresh_token.id_token.to_dict()),
} }
@ -258,9 +260,11 @@ class TokenView(View):
"access_token": refresh_token.access_token, "access_token": refresh_token.access_token,
"refresh_token": refresh_token.refresh_token, "refresh_token": refresh_token.refresh_token,
"token_type": "bearer", "token_type": "bearer",
"expires_in": timedelta_from_string( "expires_in": int(
refresh_token.provider.token_validity timedelta_from_string(
).seconds, refresh_token.provider.token_validity
).total_seconds()
),
"id_token": self.params.provider.encode(refresh_token.id_token.to_dict()), "id_token": self.params.provider.encode(refresh_token.id_token.to_dict()),
} }