Skip to content

feat: multi-tenant — let a learner choose which Open edX platform to sign in to - #670

Open
IvanStepanok wants to merge 5 commits into
openedx:developfrom
raccoongang:feat/lms-multitenant
Open

feat: multi-tenant — let a learner choose which Open edX platform to sign in to#670
IvanStepanok wants to merge 5 commits into
openedx:developfrom
raccoongang:feat/lms-multitenant

Conversation

@IvanStepanok

Copy link
Copy Markdown
Contributor

What this adds

A build of this app normally talks to exactly one Open edX site, named in
config.yaml. With LMS_DIRECTORY enabled it instead shows a list of platforms,
lets the learner pick one, re-themes to it — logo, accent colour, sign-in artwork
— and signs in against that one. Logging out returns to the list, so a device can
move between platforms without a new build.

Off by default. With ENABLED: false none of this runs and the app behaves
exactly as it does today. Every shipped config in this PR has it disabled with no
source set.

Where the list comes from

One JSON document, given either way — never both:

LMS_DIRECTORY:
  ENABLED: true
  DIRECTORY_URL: "https://example.com/lms_directory.json"   # fetched once
  DIRECTORY_FILE: ""                                        # or: "lms_directory.json" in the app target

A bundled file wins over an address: a build that ships its own copy has
deliberately opted out of the network, and quietly preferring a remote list would
undo that. Image fields inside the document are either web addresses or names of
files shipped with the app, so a build can be fully offline — list and artwork
both — and still be branded.

Because the whole list arrives at once, every platform's sign-in background is
known before anything is tapped. That is what makes it possible to warm the
artwork while the learner is still choosing, instead of watching the branded
screen assemble itself afterwards.

Format, both delivery modes and a worked example: Documentation/LMS_DIRECTORY.md.

Scope

Multi-tenancy only: read a list, choose, sign in, log out, choose again. No
search, no QR sign-in, no reporting a platform, and nothing that talks to a
catalog service — the app knows about a document and nothing else. Those belong
to a universal-app phase and will come as their own PRs.

Testing

CoreTests and AuthorizationTests: 75 tests, 0 failures on an iPhone 17 Pro
simulator. They cover which source a config resolves to, reading a document from
a URL and from the bundle (including a decoding failure, an HTTP error and a lost
connection), image sources resolving to either an address or a bundled name, the
picker's states, and a selection reaching the coordinator that re-themes the app.

One of them pins the smallest document a person could reasonably write by hand,
because the same file has to work on Android too.

Notes for reviewers

  • Theme.Images.headerBackground holds a decoded UIImage rather than a URL.
    The sign-in header used AsyncImage, which has no cache, so it refetched and
    flashed a placeholder on every appearance. Kingfisher does the fetching;
    Theme does not depend on it, because Core already depends on Theme.
  • LMSSelectionCoordinator is built inline on the main actor rather than
    registered with Swinject: the coordinator is @MainActor-isolated while
    Swinject's factory closure is not, and a registration drops the global actor.

A build normally talks to exactly one site, named in config.yaml. With
LMS_DIRECTORY enabled it instead shows the platforms listed in a JSON document,
re-themes to whichever the learner picks — logo, accent colour, sign-in artwork —
and signs in against that one. Logging out returns to the list, so a device can
move between platforms without a new build.

Off by default: with ENABLED false none of this runs.

The document is the whole contract. It comes from a URL or from a file inside
the app, and nothing downstream can tell which — so a build can ship its list and
its images and never ask the network for either. Because the whole list arrives
at once, every platform's sign-in background is known before anything is tapped,
which is what makes it possible to warm that artwork while the learner is still
choosing rather than showing a placeholder afterwards.

Image fields carry either an http(s) address or the name of a file shipped with
the app. One field, one rule: the alternative was a parallel set of *_asset
fields and a precedence rule to go with them, which puts the rule in
documentation instead of in the value.

Theme.Images.headerBackground now holds a decoded image rather than a URL. The
header used AsyncImage, which has no cache, so it refetched and flashed a
placeholder on every appearance. Kingfisher does the fetching; Theme does not
depend on it, because Core already depends on Theme.

Documentation/LMS_DIRECTORY.md has the format, both delivery modes and a worked
example.
@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 Aug 20, 2026
@openedx-webhooks

openedx-webhooks commented Aug 20, 2026

Copy link
Copy Markdown

Thanks for the pull request, @IvanStepanok!

This repository is currently maintained by @openedx/openedx-mobile-maintainers.

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.

…ader image

Every file here now opens with the same five-line block the rest of the
repository uses, and the explanation that was sitting in those blocks moved onto
the declaration it describes, as a doc comment.

One real fix came out of comparing the two platforms side by side.
Theme.Images.headerBackground is a plain static, so a screen that had already
drawn kept the stock artwork even after the selected platform's image arrived —
visible on a cold start, where the picker's prefetch has not run. It now posts a
change notification and the header view listens for it. Android, whose Coil
fills the image in when it lands, was already right.
@IvanStepanok

Copy link
Copy Markdown
Contributor Author

To test this MR you can create a JSON file by using my service: https://providers.openedx-lms.stepanok.com
Or use this JSON file: https://providers.openedx-lms.stepanok.com/p/northwind-education-group/directory.json (some of LMS in this JSON file are disabled)

@IvanStepanok
IvanStepanok marked this pull request as ready for review August 25, 2026 08:30
@codecov

codecov Bot commented Aug 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 0.00%. Comparing base (0c72bd4) to head (9392ce0).

Additional details and impacted files
@@      Coverage Diff       @@
##   develop   #670   +/-   ##
==============================
==============================

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@IvanStepanok
IvanStepanok requested review from RawanMatar89 and edschema and removed request for RawanMatar89 August 25, 2026 08:34
The mobile working group settled this the other way round from how the file was
written: a multi-instance app has one public OAuth client id of its own, and each
backend registers that id — the directory is not where per-platform credentials
live.

The runtime already worked that way: Config falls back to the app's own client id
when no platform has been selected or the selected one names none. The wire
format did not — `api` and `oauth_client_id` were required, so a document written
to the agreed model failed to decode here while Android, whose fields are already
nullable, read it fine.

`api` is now optional in full, `host_url` defaults to the address the learner
picked, and a missing client id means "the app's own". A platform that does name
one still overrides, for that platform only.
The file the apps read now says `format`, `include`, `name`, `description`,
`url` and `logo`, matching the schema being settled in the mobile working group
rather than the column names of the registry that happened to produce the first
one. A file written by hand and a file exported from a registry are now the same
shape, which was the point.

Two things fall out of the rename. `id` becomes optional — a platform that names
none is identified by its address, which is unique within a directory anyway, so
the smallest useful entry is a name and a URL. And the long `description` is
gone: it was carried through the model and never shown, while the line the list
actually draws was called `short_description`, so that one takes the plain name.

`logo_upload_url` goes with it. There is one logo per platform; which image that
is, is the publisher's decision, not something the reader should arbitrate.
@mphilbrick211 mphilbrick211 moved this from Needs Triage to Ready for Review in Contributions Aug 26, 2026
@edschema

Copy link
Copy Markdown
Contributor

Looks great: one UX piece of feedback: there's no good way to get back to the LMS site selection page if the selected site has pre-login discovery. If a learner accidentally clicks the wrong LMS that has pre-login discovery enabled, the learner has to click "sign in" and then click "change" in the selected LMS block in order to get back to the site selector.

I'm logging minor notes as well, I'll share once I've finished testing

The id came from the registry that produced the first document, where it is a
primary key. It means nothing to a client, so the schema is better without it.

What replaces it is the position in the file, not the URL. Two entries may
legitimately name the same address — the same LMS listed twice under different
branding — and my own live directory does exactly that. Identifying by URL
merges them: the list drew the second entry in the first row, and opening it
would have handed over the first entry's branding and OAuth client. That is a
wrong platform, not a cosmetic glitch, and it only shows up on a directory that
happens to contain a duplicate.

Both platforms now number the entries as they read them, and a test on each side
holds a two-entry document that shares one address.
@RawanMatar89

Copy link
Copy Markdown
Contributor

@IvanStepanok Sorry for the slow turnaround here — this has been sitting longer than it should have. I've started digging into it and will post a full review today or tomorrow at the latest. Thanks for your patience! :)

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). open-source-contribution PR author is not from Axim or 2U

Projects

Status: Ready for Review

Development

Successfully merging this pull request may close these issues.

5 participants