Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cordova-plugin-ms-adal

Package Overview
Dependencies
Maintainers
2
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cordova-plugin-ms-adal

Provides Microsoft Azure Active Directory (ADAL) OAuth client.

  • 0.6.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
75
decreased by-17.58%
Maintainers
2
Weekly downloads
 
Created
Source

Active Directory Authentication Library (ADAL) plugin for Apache Cordova apps

Active Directory Authentication Library (ADAL) plugin provides easy to use authentication functionality for your Apache Cordova apps by taking advantage of Windows Server Active Directory and Windows Azure Active Directory. Here you can find the source code for the library.

This plugin uses native SDKs for ADAL for each supported platform and provides single API across all platforms. Here is a quick usage sample:

var AuthenticationContext = Microsoft.ADAL.AuthenticationContext;

AuthenticationContext.createAsync(authority)
.then(function (authContext) {
    authContext.acquireTokenAsync(resourceUrl, appId, redirectUrl)
    .then(function (authResponse) {
        console.log("Token acquired: " + authResponse.accessToken);
        console.log("Token will expire on: " + authResponse.expiresOn);
    }, fail);
}, fail);

Note: You can use AuthenticationContext synchronous constructor as well:

authContext = new AuthenticationContext(authority);
authContext.acquireTokenAsync(resourceUrl, appId, redirectUrl).then(function (authRes) {
    console.log(authRes.accessToken);
    ...
});

For more API documentation see sample application and JSDoc for exposed functionality stored in www subfolder.

Supported platforms

  • Android
  • iOS
  • Windows (Windows 8.0, Windows 8.1 and Windows Phone 8.1)

Known issues and workarounds

'Class not registered' error on Windows

If you are using Visual Studio 2013 and see 'WinRTError: Class not registered' runtime error on Windows make sure Visual Studio Update 5 is installed.

Multiple login windows issue

Multiple login dialog windows will be shown if acquireTokenAsync is called multiple times and the token could not be acquired silently (at the first run for example). Use a promise queueing/semaphore logic in the app code to avoid this issue.

Installation Instructions

Prerequisites

To build and run sample application

  • Clone plugin repository into a directory of your choice

    git clone https://github.com/AzureAD/azure-activedirectory-library-for-cordova.git

  • Create a project and add the platforms you want to support

    cordova create ADALSample --copy-from="azure-activedirectory-library-for-cordova/sample"

    cd ADALSample

    cordova platform add android

    cordova platform add ios

    cordova platform add windows

  • Add the plugin to your project

    cordova plugin add ../azure-activedirectory-library-for-cordova

  • Build and run application: cordova run.

Setting up an Application in Azure AD

You can find detailed instructions how to set up a new application in Azure AD here.

Tests

This plugin contains test suite, based on Cordova test-framework plugin. The test suite is placed under tests folder at the root or repo and represents a separate plugin.

To run the tests you need to create a new application as described in Installation Instructions section and then do the following steps:

  • Add test suite to application

    cordova plugin add ../azure-activedirectory-library-for-cordova/tests

  • Update application's config.xml file: change <content src="index.html" /> to <content src="cdvtests/index.html" />

  • Change AD-specific settings for test application at the beginning of plugins\cordova-plugin-ms-adal\www\tests.js file. Update AUTHORITY_URL, RESOURCE_URL, REDIRECT_URL, APP_ID to values, provided by your Azure AD. For instructions how to setup an Azure AD application see Setting up an Application in Azure AD section.

  • Build and run application.

Windows Quirks

There is currently a Cordova issue, which entails the need of the hook-based workaround. The workaround is to be discarded after a fix is applied.

Using ADFS/SSO

To use ADFS/SSO on Windows platform (Windows Phone 8.1 is not supported for now) add the following preference into config.xml: <preference name="adal-use-corporate-network" value="true" />

adal-use-corporate-network is false by default.

It will add all needed application capabilities and toggle authContext to support ADFS. You can change its value to false and back later, or remove it from config.xml - call cordova prepare after it to apply the changes.

Note: You should not normally use adal-use-corporate-network as it adds capabilities, which prevents an app from being published in the Windows Store.

Copyrights

Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use these files except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Keywords

FAQs

Package last updated on 10 Mar 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc