Skip to content

fix: redirect to account MFE when using any legacy account URL - #36894

Merged
mariajgrimaldi merged 2 commits into
masterfrom
MJG/redirect-to-account-mfe-authn
Jun 18, 2025
Merged

fix: redirect to account MFE when using any legacy account URL#36894
mariajgrimaldi merged 2 commits into
masterfrom
MJG/redirect-to-account-mfe-authn

Conversation

@mariajgrimaldi

@mariajgrimaldi mariajgrimaldi commented Jun 11, 2025

Copy link
Copy Markdown
Member

Description

Redirect to the account MFE URL configured each time a legacy account URL like http(s)://lms/account/ or http(s)://lms/account/settings is used to avoid 404 errors while linking SSO accounts or simply trying to access the account view via URLs.

Supporting information

This attempts to solve #36869

Testing instructions

Go to the account or account/settings page, you must be redirected to the account MFE.

Deadline

ASAP. This is a release blocker we are solving.

⚠️ I use copilot with Claude Sonnet 4 model for code suggestions.

Redirect to the account MFE URL configured each time a legacy
account URL like http(s)://lms/account/ or http(s)://lms/account/settings
is used to avoid 404 errors while linking SSO accounts or simply
trying to access the account view via URLs.
@mariajgrimaldi
mariajgrimaldi requested a review from a team as a code owner June 11, 2025 11:05
@openedx-webhooks openedx-webhooks added open-source-contribution PR author is not from Axim or 2U core contributor PR author is a Core Contributor (who may or may not have write access to this repo). labels Jun 11, 2025
@openedx-webhooks

Copy link
Copy Markdown

Thanks for the pull request, @mariajgrimaldi!

This repository is currently maintained by @openedx/wg-maintenance-edx-platform.

Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review.

🔘 Get product approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.

Details
Where can I find more information?

If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:

When can I expect my changes to be merged?

Our goal is to get community contributions seen and reviewed as efficiently as possible.

However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@github-project-automation github-project-automation Bot moved this to Needs Triage in Contributions Jun 11, 2025
@mariajgrimaldi mariajgrimaldi added the create-sandbox open-craft-grove should create a sandbox environment from this PR label Jun 11, 2025
@sarina sarina added create-sandbox open-craft-grove should create a sandbox environment from this PR and removed create-sandbox open-craft-grove should create a sandbox environment from this PR labels Jun 11, 2025
@open-craft-grove

Copy link
Copy Markdown

Sandbox deployment successful 🚀
🎓 LMS
📝 Studio
ℹ️ Grove Config, Tutor Config, Tutor Requirements


urlpatterns = [
re_path(r'^account(?:/settings)?/?$', RedirectView.as_view(url=settings.ACCOUNT_MICROFRONTEND_URL)),
path('user_api/v1/', include(USER_API_ROUTER.urls)),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Why you made the suffix /settings in url path as optional? i

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It looks like LMS/account also returns 404 which I think should also redirect to the account mfe. What do you think?

@ghassanmas ghassanmas Jun 11, 2025

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Note sure if it's suppose to redierct from /account, AFAIK lms_base/account on sumac didn't redirect to account mfe.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Mmm I see what you say. But when using LMS base domain == MFE domain, /account will redirect to the account MFE. Does that make sense?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I made a correction in my earlier comment, I meant from lms.base/account

Mmm I see what you say. But when using LMS base domain == MFE domain, /account will redirect to the account MFE. Does that make sense?

when/if (LMS base domain == MFE domain), then it will a add new diemension to the problem, of which I haven't tried or setup before. Is there a sandbox with such setup?

@mariajgrimaldi mariajgrimaldi Jun 18, 2025

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

edunext has a few with that setup, it has another issues I think (not related to this, but to MFEs themselves) but all of them are solved here https://github.com/eduNEXT/tutor-contrib-mfe-extensions

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Aha gotcha... I think then may be since redirection is at caddy level, it would get redirected before reaching django urls roles.

Nonetheless, the project provide an intresting solution for the multiesite and MFEs.

@mariajgrimaldi

Copy link
Copy Markdown
Member Author

@BryanttV: since you were able to reproduce this issue, can you help me testing it in the remote environment?

Credentials are:
username: openedx
password: openedx

@BryanttV

Copy link
Copy Markdown
Contributor

Hi @mariajgrimaldi!, I have just tested, and the redirection works correctly, both when accessing account/settings and account. I just wonder about the reason for doing this, and not removing the references to the path where it is being used.

@mphilbrick211 mphilbrick211 moved this from Needs Triage to Ready for Review in Contributions Jun 12, 2025
@mphilbrick211 mphilbrick211 moved this from Ready for Review to In Eng Review in Contributions Jun 12, 2025
@mariajgrimaldi

mariajgrimaldi commented Jun 16, 2025

Copy link
Copy Markdown
Member Author

Thanks for reviewing, @BryanttV!

Hi @mariajgrimaldi!, I have just tested, and the redirection works correctly, both when accessing account/settings and account. I just wonder about the reason for doing this, and not removing the references to the path where it is being used.

I agree that we should remove the references to all deprecated endpoints where it's possible, but I'm not sure how much that would impact other authentication flows from other providers. I'd prefer the most straightforward approach while we coordinate how to entirely deprecate the old URLs. This might be a simple change, but we don't have a lot of time for the release.

If how well this is done becomes a blocker for merging this, then we can discuss how the other solution might look like. I think replacing the redirects to be constructed considering the MFE endpoints instead of the default backed configurations would need to be done.

Another approach would be to create a DEPR ticket to properly investigate this issue instead of rushing a fix mid-release that could break other things. But that's just my take - I'm definitely open to hearing other solutions!

USER_API_ROUTER.register(r'user_prefs', user_api_views.UserPreferenceViewSet)

urlpatterns = [
re_path(r'^account(?:/settings)?/?$', RedirectView.as_view(url=settings.ACCOUNT_MICROFRONTEND_URL)),

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.

Please add a comment here explaining why this exists. I'm generally fine with adding backwards compatibility redirects, even if we've already ripped out references to it in our own codebase (because URLs stick around for a long time in other systems).

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Thank you, agreed!

@mariajgrimaldi
mariajgrimaldi requested a review from ormsbee June 17, 2025 09:17
@open-craft-grove

Copy link
Copy Markdown

Sandbox deployment failed 💥
Please check the settings and requirements.
Retry deployment by pushing a new commit or updating the requirements/settings in the pull request's description.
📜 Failure Logs
ℹ️ Grove Config, Tutor Config, Tutor Requirements

@open-craft-grove

Copy link
Copy Markdown

Sandbox deployment successful 🚀
🎓 LMS
📝 Studio
ℹ️ Grove Config, Tutor Config, Tutor Requirements

@mariajgrimaldi
mariajgrimaldi merged commit 31ef780 into master Jun 18, 2025
@mariajgrimaldi
mariajgrimaldi deleted the MJG/redirect-to-account-mfe-authn branch June 18, 2025 13:44
@github-project-automation github-project-automation Bot moved this from In Eng Review to Done in Contributions Jun 18, 2025
mariajgrimaldi added a commit that referenced this pull request Jun 18, 2025
* fix: redirect to account MFE when using any legacy account URL

Redirect to the account MFE URL configured each time a legacy
account URL like http(s)://lms/account/ or http(s)://lms/account/settings
is used to avoid 404 errors while linking SSO accounts or simply
trying to access the account view via URLs.
farhaanbukhsh pushed a commit that referenced this pull request Jun 18, 2025
* fix: redirect to account MFE when using any legacy account URL

Redirect to the account MFE URL configured each time a legacy
account URL like http(s)://lms/account/ or http(s)://lms/account/settings
is used to avoid 404 errors while linking SSO accounts or simply
trying to access the account view via URLs.
@edx-pipeline-bot

Copy link
Copy Markdown
Contributor

2U Release Notice: This PR has been deployed to the edX staging environment in preparation for a release to production.

@edx-pipeline-bot

Copy link
Copy Markdown
Contributor

2U Release Notice: This PR has been deployed to the edX production environment.

1 similar comment
@edx-pipeline-bot

Copy link
Copy Markdown
Contributor

2U Release Notice: This PR has been deployed to the edX production environment.

marlonkeating pushed a commit that referenced this pull request Jul 15, 2025
* fix: redirect to account MFE when using any legacy account URL

Redirect to the account MFE URL configured each time a legacy
account URL like http(s)://lms/account/ or http(s)://lms/account/settings
is used to avoid 404 errors while linking SSO accounts or simply
trying to access the account view via URLs.
sumair-arbisoft pushed a commit to sumair-arbisoft/edx-platform that referenced this pull request Aug 5, 2025
…dx#36894)

* fix: redirect to account MFE when using any legacy account URL

Redirect to the account MFE URL configured each time a legacy
account URL like http(s)://lms/account/ or http(s)://lms/account/settings
is used to avoid 404 errors while linking SSO accounts or simply
trying to access the account view via URLs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core contributor PR author is a Core Contributor (who may or may not have write access to this repo). create-sandbox open-craft-grove should create a sandbox environment from this PR 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.

[Test failure] TC_LEARNER_12: Facebook sign in from account page returns 404 when linking account

9 participants