My web application is set up as follows:
- A resource server with APIs (uses Spring Security)
- An authorization server (Spring Security OAuth) which hosts the login form page
- An SPA client (Angular 6 / routing / angular-oauth-oidc library)
- I'm using the Implicit flow
I'm trying to figure out the best way to implement the login flow. As I have it now, when the user attempts to access a protected route and does not have a token, he is redirected to the auth server's login form (via a guard). If login is successful, the browser then redirects back to the angular app's protected route. The guard allows access since the user now has a token.
The issue is that I'm trying to figure out is that my angular app twice: once before I'm logged in, and again after. Modern browsers will cache the actual SPA resources (.js, .html, .css. etc), so there isn't another hit to the server. But Angular apps take a non-trivial time to load, and in this flow, the SPA loads twice.
Is there a way that I can do this such that the Angular app only loads once?