Giter Club home page Giter Club logo

node-sp-auth-config's Introduction

node-sp-auth-config - Config options builder for node-sp-auth (SharePoint Authentication in Node.js)

NPM

npm version Downloads Gitter chat

node-sp-auth-config provides wizard-like approach for building and managing config files for node-sp-auth (Node.js to SharePoint unattended http authentication). Includes CLI for generating config files from command prompt.

Versions supported:

  • SharePoint Online
  • SharePoint 2019
  • SharePoint 2016
  • SharePoint 2013

Authentication options:

  • SharePoint 2013, 2016, 2019:
    • Addin only permissions
    • User credentials through the http ntlm handshake
    • Form-based authentication (FBA)
    • Forefront TMG authentication
  • SharePoint Online:
    • Addin only permissions
    • SAML based with user credentials
    • ADFS user credentials (works with both SharePoint on-premise and Online)

How to use

Install

npm install node-sp-auth-config --save

or install globally to use as CLI:

npm install node-sp-auth-config -g

Usage as CLI

sp-auth init --path ./config/private.config.json
sp-auth --help # for help about parameters

Usage in TypeScript

import { AuthConfig } from 'node-sp-auth-config';

const authConfig = new AuthConfig({
  configPath: './config/private.json',
  encryptPassword: true,
  saveConfigOnDisk: true
});

authConfig.getContext()
  .then(context => {
    console.log(JSON.stringify(context, null, 2));
    // context.authOptions - node-sp-auth authentication options
  })
  .catch(console.warn);

Usage in JavaScript

const AuthConfig = require('node-sp-auth-config').AuthConfig;

const authConfig = new AuthConfig({
  configPath: './config/private.json',
  encryptPassword: true,
  saveConfigOnDisk: true
});

authConfig.getContext()
  .then(context => {
    console.log(JSON.stringify(context, null, 2));
    // context.authOptions - node-sp-auth authentication options
  })
  .catch(console.warn);

Initiation parameters

Parameter Default value Description
configPath './config/private.json' Path to auth config .json
encryptPassword true Encrypt password to a machine-bind hash
saveConfigOnDisk true Save config .json to disk
forcePrompts false Force parameters prompts
headlessMode false Prevents interactive prompts - for headless, CI/CD processes
defaultConfigPath empty Path to .json config, parameters from which are placed as defaults
authOptions empty Any valid node-sp-auth options

Production runtime

Headless mode

When using in a headless mode, in case of missing parameters, one can expect non-interactive behavior with no prompts but graceful exit with corresponding error output.

This can be achieved by providing headlessMode settings property is equal to true.

The headless mode also automatically configured when NODE_ENV (or SPAUTH_ENV) environment variable is equal to production.

Environment variables

All the parameters which are usually stored in private.json can be defined also using environment variables. Environment variables started with SPAUTH_ prefix are recognized with the library. Second part of the name is an actual name of the node-sp-auth credentials property yet in uppercase (e.g. SPAUTH_SITEURL, SPAUTH_USERNAME, SPAUTH_PASSWORD).

Along with credentials props these service variables are used:

Variable Description
NODE_ENV When equal to production forces headlessMode.
SPAUTH_ENV When equal to production forces headlessMode. Overwrites NODE_ENV.
SPAUTH_FORCE Makes SPAUTH_{CREDENTIALS} variables take precedence over those possibly stored in private.json.

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.