Coder Social home page Coder Social logo

adal-ts's Introduction

npm version npm license Coverage Status Build Status live demo

adal-ts

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

aka adal.js typescript rewrite

technical features:

  1. 100% typescript
  2. 80% code coverage
  3. easy to install, no dependencies.

Installation

npm install adal-ts --save

Access & ID token support

v0.6.0 adds support for access tokens for use with implicit auth flow against AAD and Office365 link

adal-ts does 4 things:

  1. login to Azure Active Directory
  2. get the logged in user
  3. logout to Azure Active Directory
  4. 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();

login with:
user: [email protected]
pwd: Test1234

source: adal-ts-consumer

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!

Building

Use webpack to compile and build. A /dist folder is generated.

npm run webpack

Code coverage

Use npm test cmd to compile and run all tests. After the tests have run a /coverage folder is generated. Drill down to index.html to see the results. code_coverage_report

Unit testing

Use npm test cmd to compile and run all tests. Test runner is configured with autowatching and 'progress' as test reporter.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.