-
Notifications
You must be signed in to change notification settings - Fork 269
MSAL React / Azure AD B2C AuthProvider sample request #157
Description
Can you please provide us with a sample that demonstrates how to create an authentication provider using MSAL React & Create React App?
I managed to find the following resources:
https://medium.com/ascentic-technology/authentication-with-msal-js-2fe281098038 (good starting point but uses older MSAL libraries + uses class components. So it's a little bit outdated. https://gist.github.com/ayeshnipun/77bae1b89dc1f69c8c6d4e44d140bd33#file-auth-provider-js (Authentication provider)
I also found this one:
https://github.com/microsoftgraph/msgraph-sample-reactspa
This one kind of demonstrates what I'm after (https://github.com/microsoftgraph/msgraph-sample-reactspa/blob/main/graph-tutorial/src/AppContext.tsx) but it also adds several other concepts. It would be nice to have like a sample SPA in this repo with only login and logout using a well-architected authentication provider pattern/solution.
I think this would be a great idea for an article on Microsoft docs and in this repo.
What I would like to see in that article/sample SPA:
- The SPA should be based on Create React App
- The react app should integrate with Azure AD B2C
- The sample should contain a well-structured AuthProvider react function component for the most common scenarios (log in, log out etc)
- The UI should have protected routes and non-protected routes (I'm thinking a simple react router dashboard type of sample with a spinner/loader/splashscreen, login, logout, registration, reset password etc)
- The AuthProvider react component should handle the authenticated / unauthenticated user
- If authenticated you should be able to see the protected routes
- If not authenticated you should not be able to see the protected routes
- Show how to do login and logout with both redirect and pop-up (like in the other samples in this repo)
- Both a .js and .tsx version of the sample
Again it would be nice to see this type of info somewhere and that you could use as a starting point.
Also, I'm curious about whether you know of any other resources where I can read more about how to build your own authentication provider using MSAL React + Azure AD B2C?