feat: logout other sessions on email change (#33846)
* feat: logout other sessions on email change * fix: updated the approach for session invalidation * fix: update and add tests * fix: update tests with descriptive comments * feat: add integration tests * fix: store email in session update * fix: add setting for tests * fix: fix tests * feat: Upgrade Python dependency edx-drf-extensions (#34135) Commit generated by workflow `openedx/edx-platform/.github/workflows/upgrade-one-python-dependency.yml@refs/heads/master` Co-authored-by: syedsajjadkazmii <syedsajjadkazmii@users.noreply.github.com> --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: syedsajjadkazmii <syedsajjadkazmii@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
7f850d6a27
commit
cb2a34e51f
@@ -309,7 +309,7 @@ class CertificatesListRestApiTest(AuthAndScopesTestMixin, SharedModuleStoreTestC
|
||||
def test_query_counts(self):
|
||||
# Test student with no certificates
|
||||
student_no_cert = UserFactory.create(password=self.user_password)
|
||||
with self.assertNumQueries(17, table_ignorelist=WAFFLE_TABLES):
|
||||
with self.assertNumQueries(21, table_ignorelist=WAFFLE_TABLES):
|
||||
resp = self.get_response(
|
||||
AuthType.jwt,
|
||||
requesting_user=self.global_staff,
|
||||
@@ -319,7 +319,7 @@ class CertificatesListRestApiTest(AuthAndScopesTestMixin, SharedModuleStoreTestC
|
||||
assert len(resp.data) == 0
|
||||
|
||||
# Test student with 1 certificate
|
||||
with self.assertNumQueries(12, table_ignorelist=WAFFLE_TABLES):
|
||||
with self.assertNumQueries(13, table_ignorelist=WAFFLE_TABLES):
|
||||
resp = self.get_response(
|
||||
AuthType.jwt,
|
||||
requesting_user=self.global_staff,
|
||||
@@ -359,7 +359,7 @@ class CertificatesListRestApiTest(AuthAndScopesTestMixin, SharedModuleStoreTestC
|
||||
download_url='www.google.com',
|
||||
grade="0.88",
|
||||
)
|
||||
with self.assertNumQueries(12, table_ignorelist=WAFFLE_TABLES):
|
||||
with self.assertNumQueries(13, table_ignorelist=WAFFLE_TABLES):
|
||||
resp = self.get_response(
|
||||
AuthType.jwt,
|
||||
requesting_user=self.global_staff,
|
||||
|
||||
@@ -434,7 +434,7 @@ class CourseListSearchViewTest(CourseApiTestViewMixin, ModuleStoreTestCase, Sear
|
||||
self.setup_user(self.audit_user)
|
||||
|
||||
# These query counts were found empirically
|
||||
query_counts = [50, 46, 46, 46, 46, 46, 46, 46, 46, 46, 16]
|
||||
query_counts = [53, 46, 46, 46, 46, 46, 46, 46, 46, 46, 16]
|
||||
ordered_course_ids = sorted([str(cid) for cid in (course_ids + [c.id for c in self.courses])])
|
||||
|
||||
self.clear_caches()
|
||||
|
||||
@@ -86,6 +86,7 @@ class CourseHomeMetadataTests(BaseCourseHomeTests):
|
||||
assert self.client.get(self.url).data['username'] == self.user.username
|
||||
|
||||
def test_get_unknown_course(self):
|
||||
self.client.logout()
|
||||
url = reverse('course-home:course-metadata', args=['course-v1:unknown+course+2T2020'])
|
||||
# Django TestCase wraps every test in a transaction, so we must specifically wrap this when we expect an error
|
||||
with transaction.atomic():
|
||||
|
||||
@@ -2238,6 +2238,9 @@ MIDDLEWARE = [
|
||||
#'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
'openedx.core.djangoapps.cache_toolbox.middleware.CacheBackedAuthenticationMiddleware',
|
||||
|
||||
# Middleware to flush user's session in other browsers when their email is changed.
|
||||
'openedx.core.djangoapps.safe_sessions.middleware.EmailChangeMiddleware',
|
||||
|
||||
'common.djangoapps.student.middleware.UserStandingMiddleware',
|
||||
'openedx.core.djangoapps.contentserver.middleware.StaticContentServer',
|
||||
|
||||
@@ -5041,6 +5044,20 @@ HIBP_LOGIN_BLOCK_PASSWORD_FREQUENCY_THRESHOLD = 5
|
||||
# .. toggle_tickets: https://openedx.atlassian.net/browse/VAN-838
|
||||
ENABLE_DYNAMIC_REGISTRATION_FIELDS = False
|
||||
|
||||
############## Settings for EmailChangeMiddleware ###############
|
||||
|
||||
# .. toggle_name: ENFORCE_SESSION_EMAIL_MATCH
|
||||
# .. toggle_implementation: DjangoSetting
|
||||
# .. toggle_default: False
|
||||
# .. toggle_description: When enabled, this setting invalidates sessions in other browsers
|
||||
# upon email change, while preserving the session validity in the browser where the
|
||||
# email change occurs. This toggle is just being used for rollout.
|
||||
# .. toggle_use_cases: temporary
|
||||
# .. toggle_creation_date: 2023-12-07
|
||||
# .. toggle_target_removal_date: 2024-04-01
|
||||
# .. toggle_tickets: https://2u-internal.atlassian.net/browse/VAN-1797
|
||||
ENFORCE_SESSION_EMAIL_MATCH = False
|
||||
|
||||
LEARNER_HOME_MFE_REDIRECT_PERCENTAGE = 0
|
||||
|
||||
############### Settings for the ace_common plugin #################
|
||||
|
||||
Reference in New Issue
Block a user