npme-auth-auth0
v2.0.1
Published
Auth0-based npme authentication module
Downloads
22
Readme
npme-auth0
Auth0-based npme authentication module
Configuring npme to use the instance
On the server:
cd /usr/local/lib/npme/data
sudo npm install npme-auth-auth0
sudo vi auth0.json
- 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
npm install -g rekcod
- this package reverse-engineers docker containerssudo rekcod npme-auth
- this will return a long command that shows how to initialise the container manually- 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 withash
- 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!
- ssh to your npm instance
cd /usr/local/lib/npme/data
sudo docker ps | grep npme-auth
to get the container id of the auth instancesudo docker exec -it [container id from previous step] less /tmp/npme-auth-auth0.log
to view the logs.