I've started building a prototype for a front-end layer with single-spa. The layout is very similar to https://github.com/react-microfrontends, which means:
- Root config
- A navbar (React)
- Two apps (Both React)
- A Styleguide module
- An API module to handle communication with a set of API
I managed to get a basic prototype running, but I now need to implement some OAuth2/OpenID based authentication, and I'm not sure where to start. I need the user redirected to a separate URL (Auth0 style) if not authenticated or not having a valid JWT, then I need a mechanism of token refresh whenever the auth token expires. On top of any general advice on best practices, existing examples and so on, I have some specific questions I can't quite work out.
- How can I redirect the user to a different URL when not authenticated? Which of the modules/components should be responsible for it?
- Is there a library that implements OAuth2 out of the box? In particular, I'm interested in some sort of automatic token refresh.
- What is the best way to make sure an unauthenticated/unauthorized user cannot access the app bundles?
Thanks in advance.
