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

feat: tpa automatic logout #32193

Merged
merged 4 commits into from
Jun 14, 2023

Conversation

kaustavb12
Copy link
Contributor

@kaustavb12 kaustavb12 commented May 7, 2023

Description

This PR adds the ability to enable automated TPA logout.

Currently, if a user is logged in through TPA and a logout_url is configured, when logging out, the user is presented with the prompt Click here to delete your single signed-on (SSO) session.

However, some Open edX operators would not want a two-step logout process and instead would prefer the user is logged out of both Open edX and the SSO with a single click. This is especially critical for use-cases such as when the learners might share terminals in their educational institutions in countries/regions with low internet penetration.

This PR adds the TPA_AUTOMATIC_LOGOUT_ENABLED django setting, which when enabled, redirects the user automatically to the TPA logout_url if it is configured.

This new django setting has no effect if logout_url is either not configured and the user is logged in directly though the LMS(using username and password).

Supporting information

Link to other information about the change, such as Jira issues, GitHub issues, or Discourse discussions.
Be sure to check they are publicly readable, or if not, repeat the information here.

Testing instructions

User sign-in using third party SSO

  1. Go to the sandbox pr32193.sandbox.do.opencraft.hosting where the changes are deployed
  2. Click on Sign In and select Cognito from the sign in with section below. You will now be redirected to the Cognito sign-in page.
  3. Login to Cognito using the following credentials:
    Username : openedx
    Email : [email protected]
    Password: openedx
  4. You should be redirected to the LMS dashboard automatically and logged in as the openedx user.
  5. Open developer tools in your browser, go the Network tab and select Preserve log or Persist logs
  6. Click Sign Out from the drop-down menu on the top right.
  7. Verify redirects to LMS /logout -> Cognito /logout -> LMS /logout -> LMS /

User sign-in without using third party SSO

  1. Go to the sandbox pr32193.sandbox.do.opencraft.hosting where the changes are deployed
  2. Click on Sign In and login through the default login form using the following credentials:
    Username : openedx
    Email : [email protected]
    Password: openedx
  3. You should be redirected to the LMS dashboard automatically and logged in as the openedx user.
  4. Open developer tools in your browser, go the Network tab and select Preserve log or Persist logs
  5. Click Sign Out from the drop-down menu on the top right.
  6. Verify redirects to LMS /logout -> LMS /.

Deadline

"None" if there's no rush, or provide a specific date or event (and reason) if there is one.

Other information

OpenCraft internal ticket BB-7398

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label May 7, 2023
@openedx-webhooks
Copy link

Thanks for the pull request, @kaustavb12! 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 as you can:

  • 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.

@kaustavb12 kaustavb12 force-pushed the kaustav/automatic_tpa_logout branch from 7e16183 to f82f66d Compare May 7, 2023 16:47
Copy link
Contributor

@navinkarkera navinkarkera left a comment

Choose a reason for hiding this comment

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

👍 @kaustavb12 Looks good, just added few suggestions related to docs.

  • I tested this: Tested logging in and out from sandbox.
  • I read through the code
  • I checked for accessibility issues
  • Includes documentation
  • I made sure any change in configuration variables is reflected in the corresponding client's configuration-secure repository.

cms/envs/common.py Outdated Show resolved Hide resolved
lms/envs/common.py Outdated Show resolved Hide resolved
@e0d
Copy link
Contributor

e0d commented May 18, 2023

@timmc-edx I see you as an author of logout.py. Is this something you could review or could you recommend a reviewer. This definitely looks useful.

@timmc-edx
Copy link
Contributor

I'll leave a few comments for the parts I understand, but I'll see if I can find someone on Vanguards to do a proper review. (They're listed as owners for the user_authn Django app.)

# .. toggle_creation_date: 2023-05-07
# .. toggle_tickets: https://github.com/openedx/edx-platform/pull/32193
TPA_AUTOMATIC_LOGOUT_ENABLED = False

Copy link
Contributor

@timmc-edx timmc-edx May 23, 2023

Choose a reason for hiding this comment

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

We should only have this defined on the LMS side -- the CMS side just redirects to LMS for logout.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@timmc-edx You are right, I added this in the CMS side only because some CMS test cases were failing. In hindsight, that was the incorrect way to go about it, I have now handled it differently and removed it from the CMS side.

# from the different IDAs. To ensure the user is logged out of all the IDAs be sure to redirect
# back to <LMS>/logout after logging out of the TPA.
# .. toggle_creation_date: 2023-05-07
# .. toggle_tickets: https://github.com/openedx/edx-platform/pull/32193
Copy link
Contributor

Choose a reason for hiding this comment

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

I think toggle_tickets is primarily used for temporary toggles, whereas this one would be intended as permanent.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed this.

# .. toggle_default: False
# .. toggle_description: Redirect the user to the TPA logout URL if this flag is enabled, the
# TPA logout URL is configured, and the user logs in through TPA.
# .. toggle_use_cases: open_edx
Copy link
Contributor

Choose a reason for hiding this comment

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

[nit] I believe this would generally be considered an opt_in toggle, although I don't have very strong feelings on this. Docs: https://edx.readthedocs.io/projects/edx-toggles/en/latest/how_to/documenting_new_feature_toggles.html

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for linking the docs.

@timmc-edx
Copy link
Contributor

(Actually, I'll let the usual contributions/maintainership process happen, rather than interfering.)

@mphilbrick211
Copy link

Hi @timmc-edx! Just seeing if you were able to find someone on the Vanguards to review/merge this?

@kaustavb12 kaustavb12 force-pushed the kaustav/automatic_tpa_logout branch from 48a5aa7 to 13a1138 Compare June 2, 2023 11:58
@mphilbrick211
Copy link

@openedx/vanguards Hi! Could someone please review this, and merge if all looks good? Thanks!

@zainab-amir
Copy link
Contributor

@mphilbrick211 we are already reviewing it. @mubbsharanwar has been assigned this ticket.

Please note that we pick these reviews based on the team's capacity for external requests and delays are to be expected.

@mubbsharanwar mubbsharanwar merged commit 489e239 into openedx:master Jun 14, 2023
@openedx-webhooks
Copy link

@kaustavb12 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future.

@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.

@kaustavb12
Copy link
Contributor Author

Thank you @timmc-edx and @mubbsharanwar for the reviews and your help to move this forward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
open-source-contribution PR author is not from Axim or 2U
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

9 participants