mitodl / micromasters

Portal for learners and course teams to access MITx Micromasters® programs
https://mm.mit.edu
BSD 3-Clause "New" or "Revised" License
28 stars 16 forks source link

Support local SSO with edx devstack #5264

Closed collinpreston closed 1 year ago

collinpreston commented 1 year ago

Pre-Flight checklist

What's this PR do?

This allows developers to more easily get OAuth SSO working between Micromasters and edX (Devstack) when running both locally. As part of this change, I am using EDXORG_BASE_URL as the outbound base URL for edX and EDXORG_CALLBACK_URL for the inbound base URL for edX which is why you will see a lot of the original instances of EDXORG_BASE_URL have now been changed to EDXORG_CALLBACK_URL.

How should this be manually tested?

Follow the updated instructions for setting up Micromasters. If you already have Micromasters running locally, then replace the following with the values shown in your .env file:

EDXORG_CALLBACK_URL=http://host.docker.internal:18000/
EDXORG_BASE_URL=http://edx.odl.local:18000/
OPENEDX_HOST_ENTRY=localhost:127.0.0.1

Verify the functionality of this PR be ensuring that you can create a new Micromasters account via SSO with edX as well as login to an existing Micromasters account via SSO with edX.

gitguardian[bot] commented 1 year ago

⚠️ GitGuardian has uncovered 2 secrets following the scan of your pull request.

Please consider investigating the findings and remediating the incidents. Failure to do so may lead to compromising the associated services or software components.

🔎 Detected hardcoded secrets in your pull request
| GitGuardian id | Secret | Commit | Filename | | | -------------- | ------------------------- | ---------------- | --------------- | -------------------- | | [5192546](https://dashboard.gitguardian.com/incidents/5192546?occurrence=74459728) | Django Secret Key | ab084e24baf8a6e11e495b4049f8520cfb78d458 | micromasters/settings.py | [View secret](https://github.com/mitodl/micromasters/commit/ab084e24baf8a6e11e495b4049f8520cfb78d458#diff-023ba10a98aea1586ce121a8a6946ad7cf899110fa8c387ef9b97a316804ecbfR43) | | [5192546](https://dashboard.gitguardian.com/incidents/5192546?occurrence=74460141) | Django Secret Key | 75f897625c04ed150494d57b8984eb386e4be64d | micromasters/settings.py | [View secret](https://github.com/mitodl/micromasters/commit/75f897625c04ed150494d57b8984eb386e4be64d#diff-023ba10a98aea1586ce121a8a6946ad7cf899110fa8c387ef9b97a316804ecbfL43) |
🛠 Guidelines to remediate hardcoded secrets
1. Understand the implications of revoking this secret by investigating where it is used in your code. 2. Replace and store your secrets safely. [Learn here](https://blog.gitguardian.com/secrets-api-management?utm_source=product&utm_medium=GitHub_checks&utm_campaign=check_run_comment) the best practices. 3. Revoke and [rotate these secrets](https://docs.gitguardian.com/secrets-detection/detectors/specifics/secret_key_in_django_config#revoke-the-secret?utm_source=product&utm_medium=GitHub_checks&utm_campaign=check_run_comment). 4. If possible, [rewrite git history](https://blog.gitguardian.com/rewriting-git-history-cheatsheet?utm_source=product&utm_medium=GitHub_checks&utm_campaign=check_run_comment). Rewriting git history is not a trivial act. You might completely break other contributing developers' workflow and you risk accidentally deleting legitimate data. To avoid such incidents in the future consider - following these [best practices](https://blog.gitguardian.com/secrets-api-management/?utm_source=product&utm_medium=GitHub_checks&utm_campaign=check_run_comment) for managing and storing secrets including API keys and other credentials - install [secret detection on pre-commit](https://docs.gitguardian.com/internal-repositories-monitoring/integrations/git_hooks/pre_commit?utm_source=product&utm_medium=GitHub_checks&utm_campaign=check_run_comment) to catch secret before it leaves your machine and ease remediation.

🦉 GitGuardian detects secrets in your source code to help developers and security teams secure the modern development process. You are seeing this because you or someone else with access to this repository has authorized GitGuardian to scan your pull request.

Our GitHub checks need improvements? Share your feedbacks!

collinpreston commented 1 year ago

Secret key warning appears to be a false positive triggered by formatting the settings.py file. No value has been added or changed on this branch.

codecov-commenter commented 1 year ago

Codecov Report

Merging #5264 (f454cbe) into master (22fde05) will increase coverage by 0.00%. The diff coverage is 90.90%.

@@           Coverage Diff           @@
##           master    #5264   +/-   ##
=======================================
  Coverage   93.68%   93.68%           
=======================================
  Files         501      501           
  Lines       23273    23275    +2     
  Branches      965      965           
=======================================
+ Hits        21804    21806    +2     
  Misses       1362     1362           
  Partials      107      107           
Impacted Files Coverage Δ
certificates/views.py 94.69% <ø> (ø)
courses/models.py 97.52% <ø> (ø)
financialaid/views.py 97.20% <ø> (ø)
ui/views.py 92.30% <ø> (ø)
backends/base.py 82.35% <66.66%> (ø)
backends/constants.py 100.00% <100.00%> (ø)
backends/edxorg.py 100.00% <100.00%> (ø)
dashboard/api.py 96.43% <100.00%> (ø)
ecommerce/views.py 92.06% <100.00%> (ø)
micromasters/settings.py 89.80% <100.00%> (+0.04%) :arrow_up:

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

collinpreston commented 1 year ago

@rachellougee, yes before we release this we should create the EDXORG_CALLBACK_URL environment variable and set it equal to the same value used for EDXORG_BASE_URL in RC and Production.

collinpreston commented 1 year ago

Related DevOps ticket for adding the environment variable: https://github.com/mitodl/ol-infrastructure/issues/1247.