Commit Graph

2373 Commits

Author SHA1 Message Date
Matthew Piatetsky
3b45a72b8e Create backend for three day streak celebration
This feature uses the first_day_of_streak, last_day_of_streak and last_streak_celebration fields to determine whether the user should see a celebration.
AA-304
2021-02-22 10:50:33 -05:00
usamasadiq
96f0915b0f Fixed new pylint warnings.
use generator in any/all()
disable not-callable warnings
disable no-member warnings
Suppressed smaller pylint warnings
Pin edx-proctoring==3.5.0
2021-02-22 16:36:53 +05:00
Jawayria
caebb910f0 BOM-2351: Removed unused imports from common/djangoapps/student 2021-02-22 13:59:32 +05:00
Aarif
802ae6343b replaced unittest assertions pytest assertions (#26527) 2021-02-18 18:08:52 +05:00
Zainab Amir
c260f72c2e VAN-311: Add multiple enterprise support for Authn MFE (#26526) 2021-02-18 17:24:44 +05:00
Manjinder Singh
cd60646926 fix: Switch anonymous user ID hash from md5 to shake (#26198)
Now that we always return an existing value from the DB rather than trusting that ID generation is deterministic and constant over time, we're free to change the generation algorithm.

Our long term goal is to switch to random IDs, but we need to first investigate the uses of save=False. In the meantime, this is a good opportunity to move away from MD5, which has a number of cryptographic weaknesses. None of the known vulnerabilities are considered exploitable in this location, given the limited ability to control the input to the hash, but we should generally be moving away from it everywhere for consistency.

This change should not be breaking even for save=False callers, since those calls are extremely rare (1 in 100,000) and should only occur after a save=True call, at which point they'll use the stored value. Even if this were not true, for a save=False/True pair of calls to result in a mismatch in output, the first of the calls would have to occur around the time of the deploy of this code.

Co-authored-by: Tim McCormack <tmccormack@edx.org>
 
Co-authored-by: Tim McCormack <tmccormack@edx.org>
2021-02-10 07:37:27 -05:00
Tim McCormack
80a4437f33 fix: Always save generated anonymous user ID in DB; ignore save=False (#26399)
This deprecates `save=False` for several functions and removes all known
usages of the parameter but does not actually remove the parameter.
Instead, it will emit a deprecation warning if the parameter is used.
We can remove the parameter as soon as we feel sure nothing is using it.

Now that we have refactored `anonymous_id_for_user` to always prefer
retrieving an existing ID from the database -- and observed that only a
small fraction of calls pass save=False -- we can stop respecting
save=False. This opens the door for future improvements, such as generating
random IDs or switching to the external user ID system.

Metrics: I observe that 1 in 16 requests for new, non-request-cached
anon user IDs are made with save=False. But 71% of all calls are served
from the request cache, and 99.7% of the misses are served from the DB.
save=False only appear to come from intermittent spikes as reports are
generated and are low in absolute number.

Also document usage/risk/rotation of secret in anonymous user ID
generation as indicated by `docs/decisions/0008-secret-key-usage.rst`
ADR on `SECRET_KEY` usage.

ref: ARCHBOM-1683
2021-02-08 19:16:05 +00:00
Tim McCormack
ac7a9f405b refactor: Remove old version of anonymous user ID generation (#26398)
In commit 2723e0e2/PR #26162, we created a new version of the
`anonymous_id_for_user` method that would make it safe to rotate the
`SECRET_KEY` setting (without changing existing anonymous IDs). This
included a toggle to allow fast reversion to the old code if needed.

This commit removes the old code and the toggle as we are satisfied with
the correctness and performance of the new code.

ref: ARCHBOM-1645
2021-02-05 15:35:16 +00:00
Bianca Severino
e5cc220d96 Merge pull request #26357 from edx/bseverino/proctored-exam-email
[MST-636] Add additional check for proctoring requirements
2021-02-04 09:09:12 -05:00
Waheed Ahmed
38187de0f9 Authn MFE: Toggle for microfrontend redirect.
VAN-308
2021-02-04 18:58:58 +05:00
Bianca Severino
3f5cbcfc6a Check for an existing proctored exam before sending proctoring requirements email 2021-02-03 15:54:52 -05:00
Kyle McCormick
3185dda123 fix: Rename send_activation_email task (step 3/3) (#26329)
The old name was
`student.send_activation_email`.

The new name is now
`common.djangoapps.student.tasks.send_activation_email`.

We no longer user the old task name,
so we can safely stop registering it with Celery
workers, without fear of dropping any lingering
tasks under the old name.
2021-02-03 11:10:01 -05:00
Kyle McCormick
1d2d59f8bd Merge pull request #26328 from edx/kdmccormick/send-activation-email-2
fix: rename send_activation_email task (step 2/3)
2021-02-03 09:09:31 -05:00
Jawayria
fbd60f1814 REsolved quality error 2021-02-03 17:01:52 +05:00
Jawayria
633b9f7060 resolved errors 2021-02-03 15:47:18 +05:00
Jawayria
45e5cbb599 Applied pylint-amnesty to student 2021-02-03 15:30:47 +05:00
Jawayria
0cdfdb7e9b Resolved issues 2021-02-03 15:29:53 +05:00
Jawayria
8086ca75f2 Applied pylint-amnesty to student 2021-02-03 15:29:53 +05:00
Kyle McCormick
21adbc4b87 fix: Rename send_activation_email task (step 2/3)
The old name is
`student.send_activation_email`.

The new name is
`common.djangoapps.student.tasks.send_activation_email`.

We currently register both the old and the new task names,
such that Celery workers recognize the task by both names.
This commit switches us from the old name to the new name.
2021-02-02 10:31:38 -05:00
Kyle McCormick
b626a43fa1 fix: Rename some tasks to match new import paths (#26236)
Several tasks are explicitly named as (or like)
their old, deprecated import path.

The issue here is that django-user-tasks listens for task
invocations, and attempts to import the task based on its name.
If the task name is completely wrong, user-tasks will catch
the ImportError and move on.
If the task is a valid *deprecated* import, though, then
user-tasks will choke on the raised `DeprecatedEdxPlatformImportError`.

Thus, we must rename three tasks to their new full path:
1. entitlements.expire_old_enrollments
2. third_party_auth.fetch_saml_metadata
3. student.send_activation_email

The first two are run daily, and so are safe to be
renamed in place.

The third task must be renamed using an expand-contract
pattern; otherwise, we would drop hundreds of tasks
during the App vs. Worker out-of-sync version window
that happens at deployments.
This commit is the expand phase.
2021-02-02 10:26:08 -05:00
Bianca Severino
42e1ac0888 Merge pull request #26182 from edx/bseverino/proctoring-requirements-email
[MST-515] Automated proctoring requirements email
2021-02-01 10:19:56 -05:00
Bianca Severino
902ab02357 Send proctoring requirements email when enrolled in relevant course mode 2021-02-01 09:44:30 -05:00
Feanil Patel
50efb38ccc Add Anonymous ID related ADR.
For a given course/user tuple, anonymous ID will not change once it
has been generated and saved.
2021-01-29 14:12:19 -05:00
Luis Moreno
a1664d2fd8 feat: Move student.courseenrollment_admin from LegacyWaffleSwitch t a WaffleSwitch and add annotations 2021-01-29 09:31:02 -04:00
adeelehsan
55d2a4f897 Logistration MFE renamed to authn
VAN-300
2021-01-29 11:37:54 +05:00
Tim McCormack
4359be96f3 Tweaks to anonymous user ID code path monitoring (#26194)
- Use different attribute names for new and old versions of function
- Use a shorter name overall (for ease of analysis)
- Add monitor for fetched-existing case
- Only record computed-stored if `get_or_create` succeeds, but also
  break it into created vs. fetched cases by checking return value
- Correct name of monitor in `except` clause -- that should only happen
  for a race inside `get_or_create` itself. There's a different race in
  the `anonymous_uid_for_user` between fetch and compute/save.
- Other name tweaks

ARCHBOM-1674
2021-01-27 16:12:55 +00:00
Muhammad Soban Javed
d26a59eb67 import task decorator from celery APP instance in CMS (#25953)
* import task decorator from celery APP instance instead of celery package in CMS

* replaced task decorator with shared_task in cms and common

* Fixed import of shared_task

* Fixed import
2021-01-27 18:35:11 +05:00
Manjinder Singh
2723e0e2bd [ARCHBOM-1645] Modifying anonymous_id_for_user() to handly SECRET_KEY rotation (#26162)
These changes were initially made to make it easier to do SECRET_KEY rotations.  Along the way, we found it made sense to refractor the code as well.

Changes made:
- changed get_to_create to create because now the code should only get to this block when a write is necessary
- added a lookup for anonymous_user_id. This is to return an existing anonymous_user_id rather than calculating. This will mitigate the results of SECRET_KEY rotation.
- Added monitoring to help us make better decisions: should we not sue SECRET_KEY, performance considerations...
- put old function behind toggle in case something goes wrong in production with new code
- refractoring function structure for better understanding
2021-01-27 07:23:19 -05:00
Tim McCormack
0fbd134c55 Add monitoring for anonymous user ID code paths (#26176)
For ARCHBOM-1674 we need more information on how often save=False is
actually used vs. other code paths.
2021-01-26 18:06:39 +00:00
Braden MacDonald
ae16394ee5 Fix: update new runtime's runtime.anonymous_student_id to store in DB
This addresses a longstanding TODO item to make runtime.anonymous_student_id for content libraries v2 work the same way as it does for XBlocks in regular courses, persisting the "context ID" (equivalent to course ID) to the database. This way, if SECRET KEY is changed, existing anonymous IDs will continue to work unchanged.

This is a potentially breaking change, but should mostly affect capa problems using external code graders or Matlab code input, and I'm not aware of any such usage of the new runtime / libraries v2.
2021-01-21 15:38:53 -08:00
Zainab Amir
7737c67588 Add query param to account activation redirect (#26107) 2021-01-21 10:18:54 +05:00
Matthew Piatetsky
53ccf9bd84 Merge pull request #25988 from edx/AA-488
[AA-488] Remove uses of the active field on the schedule model in the code.
2021-01-11 09:34:00 -05:00
Usman Khalid
9e38b17202 Convert ErrorModule and NonStaffErrorModule to XBlocks. (#25570) 2021-01-07 10:51:33 -05:00
Matthew Piatetsky
101c9b6633 Remove uses of the active field on the schedule model in the code.
Removing the active field from the model itself and the database is broken out into a separate ticket (AA-574)
AA-488
2021-01-05 18:25:44 -05:00
Kyle McCormick
643fbe82a0 Downgrade REDIRECT_TO_COURSEWARE_MICROFRONTEND to CourseWaffleFlag (#25815)
The toggle was previously an ExperimentWaffleFlag,
which allows stable A/B testing but increases the toggle's
complexity. Since we do not plan an doing any more A/B
tests as part of the MFE rollout, we can 'downgrade' this
toggle to a CourseWaffleFlag, which still allows us to do
phased rollout and course-run-specific overrides.
2020-12-09 13:48:47 -05:00
Dillon Dumesnil
354c9ada5f Merge pull request #25804 from edx/ddumesnil/aa-471
AA-471: Removing the export_staff_users command
2020-12-08 12:40:36 -08:00
Dillon Dumesnil
38a7e0b5a8 AA-471: Removing the export_staff_users command 2020-12-08 19:37:26 +00:00
Régis Behmo
a16cd71046 Start waffle namespace deprecation
By explicitly importing the legacy namespace classes, we make it clear
that we are using soon-to-be-deprecated classes. We will then be able to
start removing the legacy classes, one module at a time.
2020-12-03 16:06:14 +01:00
Saleem Latif
54f59bc3b4 Revert migration update as it creates more issues than it fixes. 2020-11-19 11:25:16 +05:00
David Ormsbee
99021bb7c3 Merge pull request #25405 from open-craft/mavidser/se-3398-fix-activation-email-context
Include common base contexts in user activation email
2020-11-18 09:37:12 -05:00
Robert Raposa
8eef18710d set code_owner for celery tasks
ARCHBOM-1260

Co-authored-by: Tim McCormack <tmccormack@edx.org>
2020-11-17 15:33:33 -05:00
Bianca Severino
60cab77c53 Merge pull request #25568 from edx/bseverino/idv-expiration
Set expiration_date field in IDVerificationAttempt model
2020-11-12 10:06:45 -05:00
Kyle McCormick
73739189c5 Undo renames of common.djangoapps tasks (#25566)
When rolling out #25477, we dropped hundreds of email activation
tasks due to the renaming of student.send_activation_email
to common.djangoapps.student.send_activation_email,
and lost more when we rolled that PR back.
This happens because of blue/green deployment:
old workers are still online for a while after deploying,
so there is a period of time when the task names are mismatched.

To prevent this from happening again, this will make
it so the import changes don't change the names of
any of the Celery tasks.
2020-11-10 16:31:48 -05:00
Bianca Severino
56d7ff8017 Set expiration_date field in IDVerificationAttempt model 2020-11-10 15:29:47 -05:00
Bianca Severino
82e8592fbe Revert "Set expiration_date field in IDVerificationAttempt model" 2020-11-10 14:24:07 -05:00
Sid Verma
b3f0df738c Include common base contexts in user activation email 2020-11-11 00:47:03 +05:30
Bianca Severino
3342524699 Update IDVerificationAttempt to use expiration_date field 2020-11-10 11:15:04 -05:00
Kyle McCormick
151bd13666 Use full names for common.djangoapps imports; warn when using old style (#25477)
* Generate common/djangoapps import shims for LMS
* Generate common/djangoapps import shims for Studio
* Stop appending project root to sys.path
* Stop appending common/djangoapps to sys.path
* Import from common.djangoapps.course_action_state instead of course_action_state
* Import from common.djangoapps.course_modes instead of course_modes
* Import from common.djangoapps.database_fixups instead of database_fixups
* Import from common.djangoapps.edxmako instead of edxmako
* Import from common.djangoapps.entitlements instead of entitlements
* Import from common.djangoapps.pipline_mako instead of pipeline_mako
* Import from common.djangoapps.static_replace instead of static_replace
* Import from common.djangoapps.student instead of student
* Import from common.djangoapps.terrain instead of terrain
* Import from common.djangoapps.third_party_auth instead of third_party_auth
* Import from common.djangoapps.track instead of track
* Import from common.djangoapps.util instead of util
* Import from common.djangoapps.xblock_django instead of xblock_django
* Add empty common/djangoapps/__init__.py to fix pytest collection
* Fix pylint formatting violations
* Exclude import_shims/ directory tree from linting
2020-11-10 07:02:01 -05:00
JJ
e5e3fcdc1c [REV-1262] Skip enrolling already enrolled users on changes to the user (#25490)
Skip auto-enrolling users if they are already enrolled in their auto-enroll enabled courses to prevent downgrading users from paid course modes to audit/free course modes when they activate their account.
2020-11-09 10:41:58 -05:00
Diane Kaplan
103ec9e0dc REV-1564: add user-metadata API, for use by Optimizely experiments (#25450) 2020-11-04 11:21:48 -05:00