-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: update jwt vs session user monitoring
1. An issue was found when both ENABLE_JWT_VS_SESSION_USER_CHECK and ENABLE_SET_REQUEST_USER_FOR_JWT_COOKIE were enabled at the same time in an ecommerce stage environment for edx.org, that is not reproducible locally. Additionally, the issue killed the requests without providing errors, so potentially caused an infinite loop or some such issue. The guess is that the code for setting the user behind ENABLE_SET_REQUEST_USER_FOR_JWT_COOKIE, and the code to get the user in the new ENABLE_JWT_VS_SESSION_USER_CHECK check, were somehow in conflict. This update skips the JWT vs Session user check in the case that we have set the user based on the JWT, in which case it would be a JWT vs JWT check, which not only is unnecessary, but also may be the cause of the issue. 2. Also adds custom attributes - set_user_from_jwt_status - skip_jwt_vs_session_check 3. Additionally, enforces JWT and session user matching when the toggle ENABLE_SET_REQUEST_USER_FOR_JWT_COOKIE is enabled, because otherwise the user in the middleware might not match the user during JWT authentication. 4. Since the JWT cookie vs session user check is an intimate part of how ENABLE_FORGIVING_JWT_COOKIES should function appropriately, this removes ENABLE_JWT_VS_SESSION_USER_CHECK as a toggle and these checks will be performed whenever ENABLE_FORGIVING_JWT_COOKIES is enabled. This makes the ENABLE_FORGIVING_JWT_COOKIES toggle more safe, because it can no longer be enabled without this required functionality. Note that the earlier tests did not cover all combinations of ENABLE_FORGIVING_JWT_COOKIES and ENABLE_JWT_VS_SESSION_USER_CHECK being disabled and enabled, and the updated tests better cover both cases for the remaining toggle. 5. Lastly, the ADR was updated to explain that various cases regarding handling of a JWT cookie user and session user mismatch.
- Loading branch information
Showing
9 changed files
with
412 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
""" edx Django REST Framework extensions. """ | ||
|
||
__version__ = '8.12.0' # pragma: no cover | ||
__version__ = '8.13.0' # pragma: no cover |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.