Skorunka František
Skorunka František

Reputation: 5430

Angular 5 and ADAL - working npm package (incl. AOT)

Is there any working npm package for ADAL and Angular 5 (AOT build)?

I did try few, but everyone had some problems.

adal-angular4plus

ERROR in node_modules/adal-angular4plus/adal4.service.d.ts(40,25): error TS2503: Cannot find namespace 'adal'. node_modules/adal-angular4plus/adal4.service.d.ts(48,22): error TS2503: Cannot find namespace 'adal'. Installing @types/adal-angular nor @types/adal helped.

ng2-adal

Did not work in AOT

ng2-adal-aot

acquireToken() after injecting the iframe it refreshes automatically the appModule. Hard to explain. But imagine the situation where you do a http request in ngOnInit of a component which is hosrted by appModule and there is a httpInterceptor which calls inside acquireToken() - the appModule gets refreshed so it is neverending cycle.

Upvotes: 2

Views: 1416

Answers (3)

kmng
kmng

Reputation: 11

You may also want to check adal-angular5, an Active Directory Authentication Library (ADAL) wrapper package for Angular 5. Uses HttpClient and HttpClientModule.

A working example using adal-angular5.

Upvotes: -1

Verona Chen
Verona Chen

Reputation: 131

Have you checked the ezcode-adal-angular5? This component:

  • was created from a angular 5 cli project and leveraged adal.js internally.
  • supports Angular 5 projects.
  • was able to authenticate users using Azure AD.
  • was able to secure the route components same as adaljs for angularjs.

you can also check a sample from https://github.com/frankchen76/EZCode-Adal-Angular5-Sample

Upvotes: 1

Loul G.
Loul G.

Reputation: 1105

In order to have adal-angular4plus work, add import { adal } from 'adal-angular'; in the .ts file where you define your configuration.

Upvotes: 1

Related Questions