Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: restore 9.1.0 JWT vs session check by username #425

Merged
merged 4 commits into from
Jan 8, 2024

Conversation

robrap
Copy link
Contributor

@robrap robrap commented Jan 5, 2024

Note to reviewer

The first commit just restores the reverted code. Review the second commit for the actual fix/changes.

Description:

The fix was to use preferred_username in place of username.
This also fixes/updates some tests for updated custom attributes.

Squashed commit message below:
Restores and fixes simplified JWT cookie vs session user check by
checking username instead of lms user id (originally introduced in
9.1.0, and removed in 9.1.1).

  • Removed VERIFY_LMS_USER_ID_PROPERTY_NAME, which is no longer
    needed.
  • Removed custom attribute jwt_auth_get_lms_user_id_status, since
    we no longer attempt to get the lms_user_id from the user object.
  • Renames custom attribute jwt_auth_mismatch_session_lms_user_id
    to jwt_auth_mismatch_session_username.
  • Adds custom attribute jwt_auth_mismatch_jwt_cookie_username.
  • Adds custom attribute jwt_cookie_unsafe_decode_issue for when
    a JWT cookie cannot even be unsafely decoded.
  • Fixes mock JWT creation for tests to use preferred_username,
    which is configured in each Open edX service.

Ticket:

Part of edx/edx-arch-experiments#429

Merge checklist:

  • All reviewers approved
  • CI build is green
  • Version bump if needed
  • Changelog record added
  • Documentation updated (not only docstrings)
  • Commits are squashed

Post merge:

  • Create a tag
  • Check new version is pushed to PyPi after tag-triggered build is
    finished.
  • Delete working branch (if not needed anymore)

robrap added 2 commits January 4, 2024 17:02
The fix was to use `preferred_username` in place of `username`.
This also fixes/updates some tests for updated custom attributes.

Squashed commit message below:
------------------------------
Restores and fixes simplified JWT cookie vs session user check by
checking username instead of lms user id (originally introduced in
9.1.0, and removed in 9.1.1).

- Removed ``VERIFY_LMS_USER_ID_PROPERTY_NAME``, which is no longer
  needed.
- Removed custom attribute ``jwt_auth_get_lms_user_id_status``, since
  we no longer attempt to get the lms_user_id from the user object.
- Renames custom attribute ``jwt_auth_mismatch_session_lms_user_id``
  to ``jwt_auth_mismatch_session_username``.
- Adds custom attribute ``jwt_auth_mismatch_jwt_cookie_username``.
- Adds custom attribute ``jwt_cookie_unsafe_decode_issue`` for when
  a JWT cookie cannot even be unsafely decoded.
- Fixes mock JWT creation for tests to use ``preferred_username``,
  which is configured in each Open edX service.

Part of edx/edx-arch-experiments#429
CHANGELOG.rst Outdated Show resolved Hide resolved
@robrap robrap merged commit 9eea525 into master Jan 8, 2024
9 checks passed
@robrap robrap deleted the robrap/fix-switch-to-username-mismatch branch January 8, 2024 20:22
robrap added a commit to robrap/ecommerce that referenced this pull request Jan 8, 2024
9.1.2 refactors ENABLE_FORGIVING_JWT_COOKIES to
use username match to compare the session user
with the JWT cookie user.

For details, see:
openedx/edx-drf-extensions#425

This is part of the rollout of:
edx/edx-arch-experiments#429
christopappas pushed a commit to openedx-unsupported/ecommerce that referenced this pull request Jan 9, 2024
9.1.2 refactors ENABLE_FORGIVING_JWT_COOKIES to
use username match to compare the session user
with the JWT cookie user.

For details, see:
openedx/edx-drf-extensions#425

This is part of the rollout of:
edx/edx-arch-experiments#429
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants