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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
* #1252 Fix crash when 'client' is in token request body
* #1496 Fix error when Bearer token string is empty but preceded by `Bearer` keyword.
* #1630 use token_checksum for lookup in _get_token_from_authentication_server
* #1597 Fix: TypeError at /s/auth/o/token/
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PR description refers to the /o/token/ endpoint, but the changelog entry records /s/auth/o/token/. This looks inconsistent and may mislead users; update the changelog entry to match the actual endpoint and wording used by the project.

Copilot uses AI. Check for mistakes.

## [3.1.0] - 2025-10-03
**NOTE**: This is the first release under the new [django-oauth](https://github.com/django-oauth) organization. The project moved in order to be more independent and to bypass quota limits on parallel CI jobs we were encountering in Jazzband. The project will emulate Django Commons going forward in it's operation. We're always on the lookout for willing maintainers and contributors. Feel free to start participating any time. PR's are always welcome.
Expand All @@ -54,7 +55,6 @@ The project is now hosted in the django-oauth organization.
* #1562 Fix: Handle AttributeError in IntrospectTokenView
* #1583 Fix: Missing pt_BR translations


## [3.0.1] - 2024-09-07
### Fixed
* #1491 Fix migration error when there are pre-existing Access Tokens.
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 @@ -897,12 +897,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()),
Comment on lines 899 to 910
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

int(timezone.now().timestamp()) can differ from Django’s dateformat.format(..., 'U') behavior (notably when USE_TZ=False, where .timestamp() on naive datetimes is interpreted in local time). For consistency with the existing codepath and Django’s formatting semantics, compute the fallback using the same mechanism as the non-null branch (i.e., format timezone.now() with 'U').

Copilot uses AI. Check for mistakes.
}
)
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", "test@example.com", "123456")
self.user.last_login = None
self.user.save()
Comment on lines +63 to +64
Copy link

Copilot AI Mar 12, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting last_login = None in setUp() adds an extra DB write for every test in this class and makes the entire class depend on a special user state (even in tests unrelated to OIDC auth_time). Prefer moving this setup into the specific test(s) that exercise the last_login is None path, or create a dedicated user within that test to keep unrelated tests isolated and faster.

Suggested change
self.user.last_login = None
self.user.save()

Copilot uses AI. Check for mistakes.
self.request = mock.MagicMock(wraps=Request)
self.request.user = self.user
self.request.grant_type = "not client"
Expand Down
Loading