Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ Abhishek Patel
Adam Johnson
Adam Zahradník
Adheeth P Praveen
Aibek Prenov
Alan Crosswell
Alan Rominger
Alejandro Mantecon Guillen
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* #1584 Fix IDP container in docker compose environment could not find templates and static files.
* #1562 Fix: Handle AttributeError in IntrospectTokenView
* #1583 Fix: Missing pt_BR translations
* #1597 Fix: TypeError at /s/auth/o/token/
<!--
### Security
-->
Expand Down
6 changes: 5 additions & 1 deletion oauth2_provider/oauth2_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -867,12 +867,16 @@ def get_id_token_dictionary(self, token, token_handler, request):
claims = self.get_oidc_claims(token, token_handler, request)

expiration_time = timezone.now() + timedelta(seconds=oauth2_settings.ID_TOKEN_EXPIRE_SECONDS)
if request.user.last_login:
auth_time = int(dateformat.format(request.user.last_login, "U"))
else:
auth_time = int(timezone.now().timestamp())
# Required ID Token claims
claims.update(
**{
"iss": self.get_oidc_issuer_endpoint(request),
"exp": int(dateformat.format(expiration_time, "U")),
"auth_time": int(dateformat.format(request.user.last_login, "U")),
"auth_time": auth_time,
"jti": str(uuid.uuid4()),
}
)
Expand Down
2 changes: 2 additions & 0 deletions tests/test_oauth2_validators.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ def always_invalid_token():
class TestOAuth2Validator(TransactionTestCase):
def setUp(self):
self.user = UserModel.objects.create_user("user", "[email protected]", "123456")
self.user.last_login = None
self.user.save()
self.request = mock.MagicMock(wraps=Request)
self.request.user = self.user
self.request.grant_type = "not client"
Expand Down
Loading