npme-auth-auth0

2.0.1 • Public • Published

npme-auth0

Auth0-based npme authentication module

Build Status

Configuring npme to use the instance

On the server:

  1. cd /usr/local/lib/npme/data
  2. sudo npm install npme-auth-auth0
  3. sudo vi auth0.json
  4. In this new file add the following config:
{
    "logLevel": "debug", // one of 'debug', 'info', 'warn', 'error'.
    "auth0Connection": "", // name of the auth0 connection
    "auth0ClientId": "", // auth0 client id
    "auth0Secret": "", // auth0 client id
    "auth0Domain": "" // auth0 domain,
    "metadataNamespace": "" // namespace used for your auth0 rules (see below)
}

In auth0:

set up a rule to enrich the profile returned with the admin and bucket properties:

function (user, context, callback) {
  const namespace = 'https://my.cool.unique.namespace';
  console.log(context.connection, context.connection === 'npme-external-users');
  if (context.connection === 'npme-external-users') {
    context.idToken[`${namespace}/admin`] = user.app_metadata.admin;
    context.idToken[`${namespace}/bucket`] = user.app_metadata.bucket;
  }

  callback(null, user, context);
}

Debugging

If the container will not start

  1. npm install -g rekcod - this package reverse-engineers docker containers
  2. sudo rekcod npme-auth - this will return a long command that shows how to initialise the container manually
  3. copy the command returned in step 2 and make the following changes: a. prefix with sudo b. remove the -d c. add the -it flag d. remove the --name npme-auth flag e. remove the --restart on failure:50000 flag f. replace /etc/npme/start.sh at the end of the command with ash
  4. execute the command you just built, and run start.sh in the new terminal. This should help you figure out what is causing the container to not start successfully.

Viewing the logs on a running instance

There's probably a better way than this, so if you know one, open a PR!

  1. ssh to your npm instance
  2. cd /usr/local/lib/npme/data
  3. sudo docker ps | grep npme-auth to get the container id of the auth instance
  4. sudo docker exec -it [container id from previous step] less /tmp/npme-auth-auth0.log to view the logs.

Readme

Keywords

none

Package Sidebar

Install

npm i npme-auth-auth0

Weekly Downloads

2

Version

2.0.1

License

ISC

Unpacked Size

34.4 kB

Total Files

16

Last publish

Collaborators

  • brandwatch