项目作者: NavaraBV

项目描述 :
NativeScript Active Directory Authentication Library plugin
高级语言: TypeScript
项目地址: git://github.com/NavaraBV/nativescript-adal.git
创建时间: 2017-09-29T07:06:04Z
项目社区:https://github.com/NavaraBV/nativescript-adal

开源协议:MIT License

下载


NativeScript Active Directory Authentication Library Plugin

Build Status
@navara/nativescript-adal"">NPM version
@navara/nativescript-adal"">Downloads
BCH compliance

This plugin allows you to quickly add Azure Active Directory Authentication to your NativeScript app

Prerequisites / Requirements

Your application requires to be registered inside your Azure Active Directory (AAD). Visit the Azure Portal and log in with your organizational account. Grab your Azure AD Tenant ID and Application ID after registering your application.

Installation

  1. tns plugin add @navara/nativescript-adal

Usage (Angular example)

Import the AdalContext class in application in, for example, an ‘AdalService’ and initialize it.

  1. import { Injectable } from '@angular/core';
  2. import { AdalContext } from '@navara/nativescript-adal';
  3. const authority: string = 'https://login.microsoftonline.com/{your-tenant-id}';
  4. const clientId: string = '{your-application-id}';
  5. const resourceId: string = '00000002-0000-0000-c000-000000000000';
  6. @Injectable()
  7. export class AdalService {
  8. public adalContext: AdalContext;
  9. constructor() {
  10. this.adalContext = new AdalContext(authority, clientId, resourceId);
  11. }
  12. }

…and consume this service in your application!

  1. export class AppComponent {
  2. constructor(private adalService: AdalService) { }
  3. public login() {
  4. this.adalService.adalContext.login().then((result) => {
  5. console.log('Success!');
  6. })
  7. }
  8. }

Known issues on iOS

Trouble running on the simulator

Open or create App_Resources/iOS/<appname>.entitlements and add these two keys with the value true:

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
  3. <plist version="1.0">
  4. <dict>
  5. <key>com.apple.keystore.access-keychain-keys</key>
  6. <true></true>
  7. <key>com.apple.keystore.device</key>
  8. <true></true>
  9. </dict>
  10. </plist>

License

See LICENSE for details.