Give us feedback
msal-plugin
Mobile icon

MSAL Plugin

Stable version 4.0.0 (Compatible with OutSystems 11)
Uploaded on 4 Jan by 
5.0
 (3 ratings)
msal-plugin

MSAL Plugin

Details
Use Microsoft MSAL to authenticate users in your application!
Read more

Cordova MSAL Plugin

So you want to integrate your mobile app with Microsoft's authentication service?

Note: All 2.x and higher versions of this plugin need MABS 7.x+ to build correctly. If you need to use a prior version of MABS, be sure to download version 1.x of this plugin.

Also, if you only want the native code without the MSAL Reactive dependency, use v3.0.0. Starting from version 4, this plugin references MSAL Reactive. The only reason for this is for ease of use when developing your app and using PreviewInDevices. When this plugin detects that Cordova is not available, it falls back to the MSAL Reactive library so that your single authentication flow works seamlessly, even in browsers.

This plugin implements Microsoft's MSAL plugin for Android and iOS. I'm assuming you're here because you've already read their documentation and understand how to configure Azure AD authentication for your organization and are simply looking for an existing Cordova wrapper to implement it on the mobile side.

Reading Microsoft's documentation, plus reading the README in my git repo of this plugin plus studying the demo found here should get you up to speed. Here's a quick guide:

Here's the JSON you'll need to configure your plugin if targeting Android. If you're building for iOS only, skip this step. If you only have one environment and build, you can put it in your extensibility configuration in your wrapper application. But you probably have debug/release builds in multiple environments with multiple keys for your Android APK, so LifeTime is probably the best place to manage your extensibility configuration JSON. Open your wrapper application implementing this plugin in LifeTime and click the Settings link near the application's title with the gear icon. Select your environment in the dropdown near the application's title, and scroll down to the Advanced section. Under Extensibility Configurations, tick the Custom > radial and paste your JSON with that environment's variables there:

{  
"plugin": {
 "url": 
"https://github.com/wrobins/cordova-plugin-msal.git#v4.0.1",
"variables": [
{
"name": "KEY_HASH",
"value": "S0m3K3yh4shH3re="
}
]
}
}

KEY_HASH is a base64 sha1 hash of your keystore file, which can be obtained like this:

keytool -exportcert -alias yourkeystorealias -keystore path/to/your/keystore/file.keystore | openssl sha1 -binary | openssl base64

You need to call the MsalInit action before you do anything else with the plugin. It tells the plugin how to function. You can call it without changing any of the input parameters, or you can modify them to suit your app. The options basically mimic Microsoft's published configuration and are documented in Service Studio's descriptions.

Release notes (4.0.0)
  • Plugin now uses Android MSAL Library 4.9.x upon build
  • Plugin no longer supports Client and Tenant IDs supplied in extensibility configuration. Instead of supplying those at build-time, provide those at runtime when calling MsalInit.
  • When removing the CLIENT_ID and TENANT_ID variables from your extensibility configuration (Only your KEY_HASH variable should be there now, if targeting Android, otherwise remove your custom extensibility config from LifeTime entirely for ease of updating in the future), please also update the plugin URL to "https://github.com/wrobins/cordova-plugin-msal.git#v4.0.1".
License (4.0.0)
Reviews (1)
by 
2020-05-07
in version 1.1.1
Works as intended out of the box. Some knowledge on Azure AD required.
Team