I have an angular application with a backend. The authentication is managed by the browser with Kerberos before the app has started. The response contains a JWT with roles in it.
My approach is an extra HTTP call to the server when the app is starting to get the users credentials. This is realized with the APP_INITIALIZER
in app.module.ts
, so I already have the credentials when the app has started.
providers: [
...,
{
provide: APP_INITIALIZER,
useFactory: Utilitys.authServiceFactory,
deps: [AuthenticationService],
multi: true
}]
This is working fine. But my question is: Do I have to make an extra call or is there a way to get the response from the browsers request?
If yes: How is it possible?
If no: Is the APP_INITIALIZER
a recommended way to fetch the data only once? Or should I protect all routes with a route guard
that does the HTTP call?