adal-typescript
A typescript library that allows you to authenticate against Azure Active Directory
aka adal.js typescript rewrite
Forked from adal-ts to fix bug.
Installation
npm install adal-typescript --save
adal-typescript does 4 things:
- login to Azure Active Directory
- get the logged in user
- logout to Azure Active Directory
- allow to retrieve the token from storage (ex: apply it to header)
Example Usage
login
let config = new AdalConfig('clientID', 'unittest.onmicrosoft.com', 'http://localhost');
let context = Authentication.getContext(config);
context.login();
...
//to process the redirect after login, place this inside your root component (ex: NG2 AppComponent.ngOnInit)
Authentication.getAadRedirectProcessor().process();
get the currently logged in user
let config = new AdalConfig('clientID', 'unittest.onmicrosoft.com', 'http://localhost');
let context = Authentication.getContext(config);
let user = context.getUser();
logout
let config = new AdalConfig('clientID', 'unittest.onmicrosoft.com', 'http://localhost');
let context = Authentication.getContext(config);
context.logout();
getToken
let config = new AdalConfig('clientID', 'unittest.onmicrosoft.com', 'http://localhost');
let context = Authentication.getContext(config);
let token = context.getToken();
Building
Use webpack
to compile and build. A /dist
folder is generated.
npm run webpack
Unit testing
Use npm test
cmd to compile and run all tests. Test runner is configured with autowatching and 'progress' as test reporter.