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
How to use library
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.
;
Configure Adal Options while importing the module.
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
;
In your routing module, add it to the routes you want to secure
;
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
:
constructorprivate adalService: BcAdalAngularService
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