machi-auth

1.0.72 • Public • Published

# NodeJS

This module is used for authentication between clients and equeum.com server, currently we are using Okta as the users managements.

Sample usage:

var app = require('express')();
var server = require('http').Server(app);
 
var MachiAuth = require('machi-auth').MachiAuth;
var machiAuth = new MachiAuth();
 
machiAuth.init(app, {
                baseURL: '< The website base url >',
               // apiKey: '< The okta api key >',
               membershipDB:'< The postgres membership database connection, see https://github.com/membership/membership.db/tree/master/postgres>',
                sendgridApiKey: "< The api key for send grid API >",
                cookies: {
                    secret: 'The cookies secret'
                }
            });
machiAuth.defineRoutes();
            
app.get('/secret page',machiAuth.middleware.loginRequired,function(req,res){
 res.json(req.user);
});

Options- You can customize the following options

Define the routes:

options.routes = {
    login: '/login',
    logout: '/logout',
    register: '/register',
    activateUser: '/activateUser',
    forgotPassword: '/forgotPassword',
    resetPassword: '/resetPassword',
    unauthorized: '/unauthorized'
}

Define the email options

options.emails={
emailTemplateFolder:'< Set to a new folder to change the default one >',
templates:{
    verify: {
        title: 'Confirm your account',
        view: 'verify-email.html'
    },
    welcome: {
        title: 'Thanks for signing up',
        view: 'welcome-email.html'
    },
    resetPassword: {
        title: 'Reset your Password',
        view: 'reset-password-email.html'
    },
    passwordChanged: {
        title: 'Your password has been changed',
        view: 'password-changed-email.html'
    },
    changeEmail: {
        title: 'Change Email',
        view: 'change-email.html'
    }
},
fromEmail:'no-reply@equeum.com',
fromEmailTitle:'Equeum'
}

AccessTokens usage

Request for new AccessToken:

Request api /tokens/requestToken

Use the AccessToken to consume the protected resources:

Include the accessToken in req.headers or req.cookies and you will be authorized

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.0.726latest

Version History

VersionDownloads (Last 7 Days)Published
1.0.726
1.0.710
1.0.700
1.0.690
1.0.680
1.0.670
1.0.660
1.0.650
1.0.640
1.0.630
1.0.620
1.0.610
1.0.600
1.0.590
1.0.580
1.0.570
1.0.560
1.0.550
1.0.540
1.0.530
1.0.520
1.0.510
1.0.500
1.0.490
1.0.480
1.0.470
1.0.460
1.0.450
1.0.440
1.0.430
1.0.420
1.0.410
1.0.400
1.0.390
1.0.380
1.0.370
1.0.360
1.0.350
1.0.340
1.0.330
1.0.320
1.0.310
1.0.300
1.0.290
1.0.280
1.0.270
1.0.260
1.0.250
1.0.240
1.0.230
1.0.220
1.0.210
1.0.200
1.0.190
1.0.180
1.0.170
1.0.160
1.0.150
1.0.140
1.0.120
1.0.110
1.0.100
1.0.90
1.0.80
1.0.70
1.0.60
1.0.50
1.0.40
1.0.30
1.0.20
1.0.10
1.0.00

Package Sidebar

Install

npm i machi-auth

Weekly Downloads

6

Version

1.0.72

License

ISC

Unpacked Size

240 kB

Total Files

32

Last publish

Collaborators

  • akramkamal