@egomobile/azuread-auth
TypeScript icon, indicating that this package has built-in type declarations

0.3.0 • Public • Published

npm last build PRs Welcome

@egomobile/azuread-auth

A middleware for @egomobile/http-server, which wraps functions of passport-azure-ad module, written for passport.

Table of contents

Install []

Execute the following command from your project folder, where your package.json file is stored:

npm install --save @egomobile/azuread-auth

Usage []

Quick example []

import createServer from "@egomobile/http-server";
import {
  initServerForAzureADBearerStrategy,
  withAzureADBearer,
} from "@egomobile/azuread-auth";

async function main() {
  const app = createServer();

  // this initializes the passport module and its global instance
  // to use bearer strategy in Azure AD context
  //
  // by default, the following environment variables are used
  // which represent the options of BearerStrategy by
  // 'passport-azure-ad' module:
  //
  // - [required] AZURE_AD_CLIENT_ID => IBearerStrategyOption.clientID
  // - [required] AZURE_AD_IDENTITY_METADATA => IBearerStrategyOption.identityMetadata
  // - [optional] AZURE_AD_AUDIENCE => IBearerStrategyOption.audience
  // - [optional] AZURE_AD_IS_B2C => IBearerStrategyOption.isB2C
  // - [optional] AZURE_AD_LOGGING_LEVEL => IBearerStrategyOption.loggingLevel
  // - [optional] AZURE_AD_POLICY_NAME => IBearerStrategyOption.policyName
  // - [optional] AZURE_AD_VALIDATE_ISSUER => IBearerStrategyOption.validateIssuer
  initServerForAzureADBearerStrategy(app);

  // use middleware by 'withAzureADBearer()' to validate and extract
  // bearer token of Azure AD instance
  app.get("/", [withAzureADBearer()], async (request, response) => {
    // at this point we have a valid token here
    console.log("authInfo", request.authInfo);
  });

  await app.listen();
}

main().catch(console.error);

Documentation []

The API documentation can be found here.

Package Sidebar

Install

npm i @egomobile/azuread-auth

Weekly Downloads

2

Version

0.3.0

License

LGPL-3.0

Unpacked Size

28.6 kB

Total Files

13

Last publish

Collaborators

  • ekmobile
  • egodux
  • mkloubert
  • ekegodigital