npm.io
7.0.5 • Published 5 years ago

adal-angular-ts

Licence
MIT
Version
7.0.5
Deps
1
Size
861 kB
Vulns
0
Weekly
0
Stars
4

npm version npm license

adal-angular-ts

A typescript library that allows you to authenticate against Azure Active Directory.

NOTE: There is a newer Microsoft library called MSAL (https://github.com/AzureAD/microsoft-authentication-library-for-js). For most usage, the MSAL library will fit your needs. However, if your usage still requires ADAL (if directly targeting ADFS 2016 or older, for example) and you have a need for TypeScript support, then this library is still a good fit.

Version 6.0.0 ^ supports Angular 6.0.0. For Support for Angular 2.0.0 > & < 6.0.0 run npm i adal-angular-ts@1.1.6.

Version 7.0.0 ^ supports Angular 7.0.0. For Support for Angular 6.0.0 > & < 7.0.0 run npm i adal-angular-ts@6.1.0.

This library was built using Angular CLI.

Installation

npm i adal-angular-ts

Example Usage

Add Module to Bootstrap of Application
import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { AppComponent } from './app.component';
import { AdalAngularTSModule, TokenInterceptor } from "adal-angular-ts";

const adalConfig = {
  clientId: '11111111-1111-1111-1111-11111111111',
  tenant: 'companyName.onmicrosoft.com',
  redirectUri: null,
  postLogoutRedirectUrl: window.location.origin,
  instance: 'https://login.microsoftonline.com/',
};

@NgModule({
  declarations: [
    AppComponent
  ],
  imports: [
    BrowserModule,
    AdalAngularTSModule.forRoot(adalConfig)
  ],
  // Adding TokenInterceptor will automatically assign the bearer token to all requests
  providers: [
        {
            provide: HTTP_INTERCEPTORS,
            useClass: TokenInterceptor,
            multi: true,
        }
  ],
  bootstrap: [AppComponent]
})
export class AppModule { }
Call Login in desired component
import { Component } from '@angular/core';
import { AdalAngularTSService } from "adal-angular-ts";

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  title = 'app';
  constructor(
    private adalService: AdalAngularTSService
  ){
    this.adalService.login();
  }
}

Issue Reporting

If you have found a bug or if you have a feature request, please report them at this repository issues section.

Contributing

Pull requests are welcome!