Skip to content

[SE-3405] Django app to allow user retirement via API - #25800

Merged
doctoryes merged 1 commit into
openedx:masterfrom
open-craft:pooja/add-gdpr-retirement-rest-api
Apr 8, 2021
Merged

[SE-3405] Django app to allow user retirement via API#25800
doctoryes merged 1 commit into
openedx:masterfrom
open-craft:pooja/add-gdpr-retirement-rest-api

Conversation

@pkulkark

@pkulkark pkulkark commented Dec 8, 2020

Copy link
Copy Markdown
Contributor

This PR adds a new django app to allow the GDPR user retirement via Open edX's REST API. Prior to this the only way to trigger the user retirement was either by the user themself clicking "Delete my account" in the account setting page or via creating a User Retirement request by admin. With these changes, the user retirement process can be triggered using REST API.

Jira Tickets: OSPR-5290

Sandbox Url:
LMS: https://pr25800.sandbox.opencraft.hosting/
Studio: https://studio.pr25800.sandbox.opencraft.hosting/

Testing Instructions:

  1. Create one or more user accounts that you want to retire.
  2. Go to the django admin -> Django Oauth Toolkit -> Application and copy the client ID and client secret for the retirement-service-backend-service.
  3. Fetch the access token for the retirement_user using the curl command:
curl -X POST -d "grant_type=client_credentials&client_id=<CLIENT_ID>&client_secret=<CLIENT_SECRET>&token_type=jwt" <LMS_URL>/oauth2/access_token
  1. Use the access token obtained in the previous step to call the gdpr_retirement_api using the curl command:
curl -X POST -d "usernames"="test_user1,test_user2" -H "Authorization: JWT <ACCESS_TOKEN>" <LMS_URL>/v1/accounts/gdpr_retire_users
  1. Go to django admin -> User_Api -> User Retirement Requests and verify that corresponding retirement requests are created for the users. Also verify that the User Retirement Status is PENDING.

Authors notes and concerns:

  • The feature allows for multiple users to be retired. The usernames should be passed in as a comma separated strings as shown in the testing instructions.

Reviewers:

@openedx-webhooks openedx-webhooks added needs triage open-source-contribution PR author is not from Axim or 2U labels Dec 8, 2020
@openedx-webhooks

Copy link
Copy Markdown

Thanks for the pull request, @pkulkark! I've created OSPR-5290 to keep track of it in JIRA, where we prioritize reviews. Please note that it may take us up to several weeks or months to complete a review and merge your PR.

Feel free to add as much of the following information to the ticket:

  • supporting documentation
  • Open edX discussion forum threads
  • timeline information ("this must be merged by XX date", and why that is)
  • partner information ("this is a course on edx.org")
  • any other information that can help Product understand the context for the PR

All technical communication about the code itself will be done via the GitHub pull request interface. As a reminder, our process documentation is here.

Please let us know once your PR is ready for our review and all tests are green.

@natabene

Copy link
Copy Markdown
Contributor

@pkulkark Thank you for your contribution. Please let me know once this is ready for our review.

@pkulkark
pkulkark force-pushed the pooja/add-gdpr-retirement-rest-api branch from 1da08d0 to b22471d Compare December 15, 2020 12:22
@openedx-webhooks openedx-webhooks added waiting on author PR author needs to resolve review requests, answer questions, fix tests, etc. and removed needs triage labels Dec 15, 2020

@mavidser mavidser left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM 👍

  • I tested this: I retired existing users (single & multiple) and tested error cases.
  • I read through the code
  • Includes documentation

@mavidser

Copy link
Copy Markdown
Contributor

@natabene This should be ready for edx's review now

@bradenmacdonald bradenmacdonald left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Not sure if I'll be doing the technical review here or not, once it gets to that point, but I had some preliminary questions and comments.

Comment thread cms/envs/common.py Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Do we need this app in Studio? I feel like having it only in the LMS would be sufficient, but I might be missing something.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Since the user accounts are shared with Studio, I thought it should be available there too. Please let me know if that's not required.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I don't know the answer to whether or not it needs to be available in the CMS as well as the LMS. But if Studio starts up/operates fine without this app being included, it should be removed.

@jmbowman In what conditions would a Django app need to be required in both the LMS and CMS? When it defines 1+ Django models? Some other condition? Does this app need to be included in the CMS here?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

My impression is that this whole workflow is usually called just "user retirement" and that GDPR compliance is one, but not necessarily the only, use case for the user retirement flow. Is there a specific reason to call this new django app "GDPR user retirement" vs. "user retirement" or "user retirement REST API" ?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

There's no specific reason. I just went with that in order to differentiate from the existing retirement related code. Also noticed GDPR usually being mentioned alongside user retirement: like here for example.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I would prefer that this Django app (and feature) be called bulk_user_retirement without specifically referring to the GDPR. That name more accurately reflects the feature - and makes no implied claims about GDPR compliance.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Thank you. That's a great suggestion. I've changed it to bulk_user_retirement and removed the GDPR reference everywhere.

Comment thread lms/djangoapps/gdpr_user_retirement/tests/test_views.py Outdated
Comment thread lms/djangoapps/gdpr_user_retirement/views.py Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Nit: it's confusing that this variable is called request_body, because it's not the request body, it's a specific request parameter value, which was decoded from the request body.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Makes sense. I changed it to request_usernames.

Comment thread lms/djangoapps/gdpr_user_retirement/views.py Outdated
Comment thread lms/djangoapps/gdpr_user_retirement/views.py Outdated
@natabene natabene removed the waiting on author PR author needs to resolve review requests, answer questions, fix tests, etc. label Jan 15, 2021
@pkulkark
pkulkark force-pushed the pooja/add-gdpr-retirement-rest-api branch from bbbeadf to 3259085 Compare January 20, 2021 07:04
nizarmah pushed a commit to open-craft/openedx-platform that referenced this pull request Jan 20, 2021
(cherry picked from commit b22471d6760aa8e874e947de15144d2262696fd8)
@bradenmacdonald

Copy link
Copy Markdown
Contributor

@pkulkark Thanks for addressing the review; sorry I haven't re-reviewed yet. Will do so tomorrow.

@bradenmacdonald

Copy link
Copy Markdown
Contributor

Actually from Jira it looks like @macdiesel will be reviewing this, which is great as I'm not super familiar with user retirement.

@macdiesel

Copy link
Copy Markdown
Contributor

Hey all, so we deliberately did not write this feature as we wanted to ensure that retirements could only be executed by the users requesting them. Thank you for the submission but I'm inclined to close this PR. I'm curious though, what is the use case here? Is this a use case edX needs?

@bradenmacdonald

Copy link
Copy Markdown
Contributor

@macdiesel I'll let @pkulkark clarify the use case when she can, but I think it could be this:

Say you're a company that offers a suite of services to your customer - they enroll in your portal, and then you provision accounts for them on your Discourse forum, your Open edX LMS, your Zendesk, your Slack, and so on - all with one master login via your customer portal (single sign-on). Some time later they decide to close their account and request GDPR deletion of all the data that your company has about them. In the same way that you provisioned all their various accounts automatically, you now want to retire them all via an API.

Another similar case is employee onboarding/offboarding - someone joins edX, they get their account created automatically; they leave edX, their account gets retired automatically. (edX probably doesn't do that but you can see how other orgs may want that.)

0x29a pushed a commit to open-craft/openedx-platform that referenced this pull request Feb 15, 2021
(cherry picked from commit b22471d6760aa8e874e947de15144d2262696fd8)
@pkulkark

pkulkark commented Mar 1, 2021

Copy link
Copy Markdown
Contributor Author

Thanks @bradenmacdonald, that's exactly the use case here. CC @macdiesel

@pdpinch

pdpinch commented Mar 1, 2021

Copy link
Copy Markdown
Contributor

We have the same use case at MIT Open Learning:

In the same way that you provisioned all their various accounts automatically, you now want to retire them all via an API.

@natabene

natabene commented Mar 1, 2021

Copy link
Copy Markdown
Contributor

@macdiesel Actually, we had the same use case at one of our White Label sites. This is a desirable feature when you have an Open edX instance and you are bound by a contract with your corporate client to remove all their data, including user data, from your instance after the contract ends.

@macdiesel

Copy link
Copy Markdown
Contributor

If a feature flag could be added for this that would disable the feature on edx.org I'll pass the PR to one of the engineers on the team for review.

@pkulkark

pkulkark commented Apr 8, 2021

Copy link
Copy Markdown
Contributor Author

@doctoryes Addressed the remaining comments 🙂

@doctoryes

Copy link
Copy Markdown
Contributor

Thanks for sticking with all the requested changes here, @pkulkark ! Looks good - I'll merge now.

@doctoryes

Copy link
Copy Markdown
Contributor

Ohh - oops! @pkulkark : The new edx-platform standard is to use conventional commit messages:

https://open-edx-proposals.readthedocs.io/en/latest/oep-0051-bp-conventional-commits.html

Could you please squash/rebase your commits to conform to this new standard? Thank you!

@doctoryes doctoryes left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Merge blocked on conventional commits.

@pkulkark

pkulkark commented Apr 8, 2021

Copy link
Copy Markdown
Contributor Author

Thank you so much for the review @doctoryes! I've squashed the commits to use the new standard.

@doctoryes

Copy link
Copy Markdown
Contributor

@pkulkark Looks like something happened during the rebase - now shows 288 files changed?

@pkulkark

pkulkark commented Apr 8, 2021

Copy link
Copy Markdown
Contributor Author

@doctoryes Sorry about that! Will fix that right away

This adds a new django app to allow the GDPR user retirement via
Open edX's REST API. Prior to this the only way to trigger the user
retirement was either by the user themself clicking "Delete my account"
in the account setting page or via creating a User Retirement request
by admin. With these changes, the user retirement process can be
triggered using REST API.
@pkulkark
pkulkark force-pushed the pooja/add-gdpr-retirement-rest-api branch from fac5076 to 162fd44 Compare April 8, 2021 16:56
@edx-status-bot

Copy link
Copy Markdown

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

@doctoryes
doctoryes merged commit 86bfcea into openedx:master Apr 8, 2021
@openedx-webhooks

Copy link
Copy Markdown

@pkulkark 🎉 Your pull request was merged!

Please take a moment to answer a two question survey so we can improve your experience in the future.

@doctoryes

Copy link
Copy Markdown
Contributor

Thanks again, @pkulkark !

@edx-pipeline-bot

Copy link
Copy Markdown
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
Copy Markdown
Contributor

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

0x29a pushed a commit to open-craft/openedx-platform that referenced this pull request Apr 20, 2021
(cherry picked from commit b22471d6760aa8e874e947de15144d2262696fd8)
@xitij2000
xitij2000 deleted the pooja/add-gdpr-retirement-rest-api branch November 8, 2021 05:13
xitij2000 pushed a commit to open-craft/openedx-platform that referenced this pull request Nov 22, 2021
(cherry picked from commit b22471d6760aa8e874e947de15144d2262696fd8)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged open-source-contribution PR author is not from Axim or 2U

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants