3.0.5 • Published 2 years ago

node-sp-auth-config v3.0.5

Weekly downloads
6,583
License
MIT
Repository
github
Last release
2 years ago

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

NPM

npm version Downloads Actions Status FOSSA Status 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 a command prompt.

Versions supported:

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

Authentication options:

  • SharePoint Online:
    • User credentials (SAML/ADFS)
    • Add-In Only permissions
    • On-Demand authentication (using Electron popup)
  • SharePoint 2019, 2016, 2013:
    • User credentials (NTLM, NTLM v2)
    • ADFS user credentials
    • Form-based authentication (FBA)
    • Form-based authentication (Forefront TMG)
    • Add-In Only permissions
    • On-Demand authentication (using Electron popup)
  • SharePoint 2010:
    • User credentials (NTLM, NTMLv2)
    • Form-based authentication (FBA)
    • Form-based authentication (Forefront TMG)

Config layer and auth support Office 365 Dedicated (SPO on a custom domain) as well.


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

ParameterDefault valueDescription
configPath'./config/private.json'Path to auth config .json
encryptPasswordtrueEncrypt password to a machine-bind hash
saveConfigOnDisktrueSave config .json to disk
forcePromptsfalseForce parameters prompts
headlessModefalsePrevents interactive prompts - for headless, CI/CD processes
defaultConfigPathemptyPath to .json config, parameters from which are placed as defaults
authOptionsemptyAny 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. The 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:

VariableDescription
NODE_ENVWhen equal to production forces headlessMode.
SPAUTH_ENVWhen equal to production forces headlessMode. Overwrites NODE_ENV.
SPAUTH_FORCEMakes SPAUTH_{CREDENTIALS} variables take precedence over those possibly stored in private.json.

Configuring CI/CD

Checkout this end-to-end sample.

License

FOSSA Status

3.0.4

2 years ago

3.0.3

2 years ago

3.0.5

2 years ago

3.0.2

2 years ago

3.0.1

4 years ago

3.0.0

4 years ago

3.0.0-beta.0

4 years ago

2.9.4

4 years ago

2.9.3

4 years ago

2.9.2

4 years ago

2.9.1

4 years ago

2.9.0-beta.0

4 years ago

2.8.0

5 years ago

2.7.0

5 years ago

2.6.7

5 years ago

2.6.6

5 years ago

2.6.5

5 years ago

2.6.4

5 years ago

2.6.3

5 years ago

2.6.3-beta1

5 years ago

2.6.2

5 years ago

2.6.1

5 years ago

2.6.0

5 years ago

2.5.8

5 years ago

2.5.7

5 years ago

2.5.6

6 years ago

2.5.5

6 years ago

2.5.4

6 years ago

2.5.3

6 years ago

2.5.2

6 years ago

2.5.2-beta

6 years ago

2.5.0-beta1

6 years ago

2.0.0-beta1

6 years ago

2.4.5

6 years ago

2.4.4

6 years ago

2.4.3

6 years ago

2.4.2

6 years ago

2.4.1

6 years ago

2.3.1

6 years ago

2.3.0

6 years ago

2.2.0

6 years ago

2.1.1

6 years ago

2.1.0

6 years ago

2.0.11

6 years ago

2.0.10

6 years ago

2.0.9

7 years ago

2.0.8

7 years ago

2.0.7

7 years ago

2.0.6

7 years ago

2.0.5

7 years ago

2.0.4

7 years ago

2.0.3

7 years ago

2.0.2

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.10

7 years ago

1.0.9

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago