Version 13 to 14
In this version the APP_INITIALIZER was removed. (See PR). The library will not do anything until the application interact with it. There is no pre-loading of anything and it does not affect your application's bootstrapping process at all. You can however explicitly preload the secure token server well-known endpoints with a new method called preloadAuthWellKnownDocument(). As a side effect because the config has to be loaded first, a lot of APIs become reactive and return an Observable now.
All changes are described below.
eagerLoadAuthWellKnownEndpoints
was removed
The secure token server well known endpoints are always eager loaded expect loading it explicitly using thepreloadAuthWellKnownDocument() method. No option needed anymore.
getConfiguration
now returns an Observable
Old:
const singleConfig = this.oidcSecurityService.getConfiguration();
New:
this.oidcSecurityService.getConfiguration().subscribe((config)=> ... );
getUserData
now returns an Observable
Old:
const userData = this.oidcSecurityService.getUserData();
New:
this.oidcSecurityService.getUserData().subscribe((data)=> ... );
checkAuthMultiple
does not take a configId
parameter anymore.
If you want to check a single config, use checkAuth
with a configId
param instead.
Old:
checkAuthMultiple(url?: string, configId?: string)
New:
checkAuthMultiple(url?: string)
isAuthenticated
now returns an Observable
Old:
const isAuthenticated = this.oidcSecurityService.isAuthenticated();
New:
this.oidcSecurityService.isAuthenticated().subscribe((isAuthenticated)=> ... );
getAccessToken
now returns an Observable
Old:
const accessToken = this.oidcSecurityService.getAccessToken();
New:
this.oidcSecurityService.getAccessToken().subscribe(/*...*/);
getIdToken
now returns an Observable
Old:
const idToken = this.oidcSecurityService.getIdToken();
New:
this.oidcSecurityService.getIdToken().subscribe(/*...*/);
getRefreshToken
now returns an Observable
Old:
const refreshToken = this.oidcSecurityService.getRefreshToken();
New:
this.oidcSecurityService.getRefreshToken().subscribe(/*...*/);
getAuthenticationResult
now returns an Observable
Old:
const authnResult = this.oidcSecurityService.getAuthenticationResult();
New:
this.oidcSecurityService.getAuthenticationResult().subscribe(/*...*/);
getPayloadFromIdToken
now returns an Observable
Old:
const payload = this.oidcSecurityService.getPayloadFromIdToken();
New:
this.oidcSecurityService.getPayloadFromIdToken().subscribe(/*...*/);
setState
now returns an Observable
Old:
this.oidcSecurityService.setState('some-state');
New:
this.oidcSecurityService.setState('some-state').subscribe(/*...*/);
getState
now returns an Observable
Old:
const state = this.oidcSecurityService.getState();
New:
this.oidcSecurityService.getState().subscribe(/*...*/);
getEndSessionUrl
now returns an Observable
Old:
const endSessionUrl = this.oidcSecurityService.getEndSessionUrl();
New:
this.oidcSecurityService.getEndSessionUrl().subscribe(/* ... */);
Providing a Custom Storage Service
The storage
property was removed of the config to provide a better usage to use an own custom storage. With the new syntax, you can pass your own service in a better way and even pass custom dependencies using the Dependency providers of Angular.
import { AbstractSecurityStorage } from 'angular-auth-oidc-client';
@Injectable()
export class CustomStorage implements AbstractSecurityStorage {
// ...
}
Old:
@NgModule({
imports: [
// ...
AuthModule.forRoot({ config: { storage: new CustomStorage() } })
],
// ...
})
New:
@NgModule({
imports: [
AuthModule.forRoot({
config: {
// ...
},
}),
],
providers: [{ provide: AbstractSecurityStorage, useClass: MyStorageService }],
exports: [AuthModule],
})
export class AuthConfigModule {}