Skip to content

Conversation

@timmc-edx
Copy link
Contributor

Description

This is intended to silence a rare false positive that seems to happen when someone logs in on a browser that already has an active session for another user. We believe there should be no further positives once this case is handled.

  • login and logout views annotate the response to indicate the session user should be changing between the request and response phases
  • safe-sessions middleware skips the verify-user check when this annotation is present

Also improve tests and docs and remove an old workaround for the logout case.

Affected roles

LMS operators.

Supporting information

Ticket: ARCHBOM-1878

Testing instructions

  • Log out
  • Open login page in two tabs
  • Log into one account in first tab
  • Log into another account in second tab
  • Confirm that log messages and custom attributes do not fire

Deadline

None

@timmc-edx timmc-edx marked this pull request as draft October 7, 2021 22:01
This adds a test around what actually happens when an unexpected
user-change happens.
Revert most of af9e26f/PR #11479 for two reasons:

- The safe-sessions `_verify_user` code has since changed to check for
  `request.user.id == None`
- A commit later in the PR changes the login and logout pages to
  signal that the user/session change is expected
This is intended to silence a rare false positive that seems to happen when
someone logs in on a browser that already has an active session for another
user. We believe there should be no further positives once this case is
handled.

- login and logout views annotate the response to indicate the session user
  should be changing between the request and response phases
- safe-sessions middleware skips the verify-user check when this
  annotation is present

ref: ARCHBOM-1878
@timmc-edx timmc-edx force-pushed the timmc/1878-safe-session-exempt-login branch from a9c1702 to 484b1d9 Compare October 8, 2021 14:16
@timmc-edx timmc-edx marked this pull request as ready for review October 8, 2021 16:10
# page is used during an active session.
#
# The relevant views set a flag to indicate the exemption.
if getattr(response, 'safe_sessions_expected_user_change', None):
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This just checks if it is present, like a flag. I was thinking of actually using the new_user_id present in the dict to validate that it matches up, which would of course add a different thing we might alert on...

(and interpolate the actual user IDs rather than hardcoding)
@edx-status-bot
Copy link

Your PR has finished running tests. There were no failures.

@timmc-edx timmc-edx merged commit fe3d855 into master Oct 13, 2021
@timmc-edx timmc-edx deleted the timmc/1878-safe-session-exempt-login branch October 13, 2021 15:53
@edx-pipeline-bot
Copy link
Contributor

EdX Release Notice: This PR has been deployed to the staging environment in preparation for a release to production.

@edx-pipeline-bot
Copy link
Contributor

EdX Release Notice: This PR has been deployed to the production environment.

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.

4 participants