51 lines
1.6 KiB
TypeScript
51 lines
1.6 KiB
TypeScript
import { ApplicationConfig, provideBrowserGlobalErrorListeners } from '@angular/core';
|
|
import {provideRouter, withComponentInputBinding} from '@angular/router';
|
|
import {provideHttpClient, withInterceptors} from '@angular/common/http';
|
|
|
|
import { provideStore } from '@ngrx/store';
|
|
|
|
import {
|
|
AutoRefreshTokenService, provideKeycloak, UserActivityService, withAutoRefreshToken,
|
|
INCLUDE_BEARER_TOKEN_INTERCEPTOR_CONFIG, IncludeBearerTokenCondition, includeBearerTokenInterceptor,
|
|
createInterceptorCondition
|
|
} from 'keycloak-angular';
|
|
|
|
import {environment} from '../environments/environment';
|
|
|
|
import { routes } from './app.routes';
|
|
|
|
const devUrlCondition = createInterceptorCondition<IncludeBearerTokenCondition>({
|
|
urlPattern: /^(http:\/\/localhost:8000)(\/.*)?$/i,
|
|
bearerPrefix: 'Bearer'
|
|
});
|
|
|
|
export const appConfig: ApplicationConfig = {
|
|
providers: [
|
|
provideKeycloak({
|
|
config: {
|
|
clientId: environment.keycloakClient,
|
|
realm: environment.keycloakRealm,
|
|
url: environment.keycloakUrl
|
|
},
|
|
initOptions: {
|
|
onLoad: 'login-required'
|
|
},
|
|
features: [
|
|
withAutoRefreshToken({
|
|
onInactivityTimeout: 'login',
|
|
sessionTimeout: 60000
|
|
})
|
|
],
|
|
providers: [AutoRefreshTokenService, UserActivityService]
|
|
}),
|
|
{
|
|
provide: INCLUDE_BEARER_TOKEN_INTERCEPTOR_CONFIG,
|
|
useValue: [devUrlCondition,]
|
|
},
|
|
provideBrowserGlobalErrorListeners(),
|
|
provideRouter(routes, withComponentInputBinding()),
|
|
provideHttpClient(withInterceptors([includeBearerTokenInterceptor])),
|
|
provideStore()
|
|
]
|
|
};
|