@xyzblocks/ng-open-id-guard
v1.0.0
Published
Angular OpenID Guard
Downloads
1
Readme
@xyzblocks/ng-open-id-guard
Angular OpenID Guard
Installation
npm install --save @xyzblocks/ng-open-id-guard
API
DemoIdentityServer4OpenIDService extends OpenIDService
Methods
authenticated(): Observable<boolean>
callback(): void
getUser(): any
isLoggedIn(): boolean
signIn(): Observable<boolean>
signOut(): void
OpenIDGuard
Methods
canActivate(next: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<boolean> | Promise<boolean> | boolean
Example
@NgModule({
declarations: [AppComponent, HomeRouteComponent],
imports: [
RouterModule.forRoot([{ path: '', component: HomeRouteComponent, canActivate: [OpenIDGuard] }]);
],
providers: [
{
provide: OpenIDService,
useClass: MyCuston4OpenIDService,
},
],
bootstrap: [AppComponent],
})
export class AppModule {}
@Injectable()
export class MyCuston4OpenIDService extends OpenIDService {
constructor(router: Router) {
super(
{
authority: 'https://demo.identityserver.io',
client_id: 'implicit',
redirect_uri: `http://localhost:4200/callback`,
scope: 'openid profile',
post_logout_redirect_uri: 'http://localhost:4200',
},
router,
);
}
}
OpenIDService
Methods
authenticated(): Observable<boolean>
callback(): void
getUser(): any
isLoggedIn(): boolean
signIn(): Observable<boolean>
signOut(): void