npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

bc-adal-angular

v0.0.6

Published

Library wrapper for Angular 6+, development over Microsoft ADAL (Azure Active Directory Authentication Library) - [https://github.com/AzureAD/azure-activedirectory-library-for-js](https://github.com/AzureAD/azure-activedirectory-library-for-js) that helps

Downloads

22

Readme

BC Adal Angular Library

Active Directory Authentication Library (ADAL) for Angular6

Library wrapper for Angular 6+, development over Microsoft ADAL (Azure Active Directory Authentication Library) - https://github.com/AzureAD/azure-activedirectory-library-for-js that helps you integrate with Microsoft's AAD (Azure Active Directory).


For information on how to configure Azure Active Directory refer - https://docs.microsoft.com/en-us/azure/app-service/app-service-mobile-how-to-configure-active-directory-authentication

Step 1: Install the package

npm i --save bc-adal-angular

Step 2: Import BcAdalAngularModule and configure Adal Options

In the root module of your application, import the BcAdalAngularModule module.

import { BcAdalAngularModule } from 'bc-adal-angular';

Configure Adal Options while importing the module.

@NgModule({
  imports: [
    BcAdalAngularModule.forRoot({
      tenant: '[Enter your tenant]',
      clientId: '[Enter your client_id here, e.g. g075edef-0efa-453b-997b-de1337c29185]',
      redirectUri: window.location.origin,
      // ...
    }),
    // ...
  ],
  // ...
})

For a list of all available adal configuration options, refer: https://github.com/AzureAD/azure-activedirectory-library-for-js/wiki/Config-authentication-context#configurable-options

Step 3: Secure individual routes of Angular

Use the AdalAccessGuard to secure indivuadual routes in your application. Import AdalAccessGuard and add it as a provider in your root module.

Note: This step it's optional, because the BcAdalAngularModule import the guard provider automatically

import { AdalAccessGuard } from 'bc-adal-angular';
@NgModule({
    providers: [
        // ...
        AdalAccessGuard,
        // ...
    ],
    // ...
})

In your routing module, add it to the routes you want to secure

const routes: Routes = [
  {
    path: '',
    component: AppComponent,
    pathMatch: 'full',
    canActivate: [AdalAccessGuard]
  }
];

@NgModule({
  imports: [RouterModule.forRoot(routes)],
  exports: [RouterModule]
})
export class AppRoutingModule {
  /* ... */
}

Step 4 (Optional): Generating resource tokens

To generate resource level tokens for APIs your website may consume, specify the resources in your endpoints array while injecting AdalOptions into BcAdalAngularModule via root. Then to generate token, use getAccessToken() of BcAdalAngularService:

constructor(private adalService: BcAdalAngularService) {
  this.adalService
    .getAccessToken(
        endpoint: string,
        callbacks: (message: string, token: string) => any)
    .subscribe((resToken: string) => {
      console.log(resToken);
    });
}

Step 5 (Optional): Getting logged-in user info

At any point in you application, to get the logged-in user info, use:

this.adalService.userInfo;

With these steps your application should be up and running with ADAL.

Important links

  1. Azure Active Directory Overview
  2. Configure Azure Active Directory
  3. Azure Active Directory Pricing
  4. Active Directory Authentication Library (ADAL) for JavaScript