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

Refactor MSAL integration #63

Merged
merged 1 commit into from
Nov 17, 2023
Merged

Refactor MSAL integration #63

merged 1 commit into from
Nov 17, 2023

Conversation

bcspragu
Copy link
Collaborator

@bcspragu bcspragu commented Nov 17, 2023

This PR basically just moves all Azure auth integration into the $msal plugin, and makes it not client-only.

The problem with useMSAL being an async composable is that it made everything downstream async, which causes utter chaos when it comes to loading things, as now it's all happening multiple times and potentially 'in parallel'.

I think I had originally tried to make useMSAL a composable so that we'd only try to load auth on pages that needed it, but things like the NavBar mean we always need that anyway, so the next logical step is to realize that it should just be a plugin, and happen before we do anything else. But since we use auth stuff everywhere, it can't just be a client-side plugin, it needs to run on the server to, and just fail if we try to do auth things during SSR (much like useMSAL did before anyway)

This should fix the problems I was seeing, which were manifesting as issues in FakeUsers and StandardNav because they call a few composables that are kinda at different levels of the dependency hierarchy.

Diagram:

The downside of this approach is mainly that plugins/msal.ts is now monstrously large, but all the auth stuff is now contained in one file, which will make it easy to backport to OPGEE.

This PR basically just moves all Azure auth integration into the `$msal` plugin, and makes it not client-only.

The problem with `useMSAL` being an async composable is that it made everything downstream async, which causes utter chaos when it comes to loading things, as now it's all happening multiple times and potentially 'in parallel'.

I think I had originally tried to make `useMSAL` a composable so that we'd only try to load auth on pages that needed it, but things like the NavBar mean we _always_ need that anyway, so the next logical step is to realize that it should just be a plugin, and happen before we do anything else. But since we use auth stuff everywhere, it can't just be a client-side plugin, it needs to run on the server to, and just fail if we try to do auth things during SSR (much like `useMSAL` did before anyway)

This should fix the problems I was seeing, which were manifesting as issues in `FakeUsers` and `StandardNav` because they call a few composables that are kinda at different levels of the dependency hierarchy.
@bcspragu bcspragu marked this pull request as ready for review November 17, 2023 20:57
@bcspragu bcspragu requested a review from gbdubs November 17, 2023 20:57
Copy link
Contributor

@gbdubs gbdubs left a comment

Choose a reason for hiding this comment

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

Nice - solid refactor. Glad to not be doing await on every composable.

@bcspragu bcspragu merged commit 6ffdbda into main Nov 17, 2023
2 checks passed
@bcspragu bcspragu deleted the brandon/re-sync branch November 17, 2023 21:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants