šŸš€ Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more →
Socket
Sign inDemoInstall
Socket

jupiter-auth-handler

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jupiter-auth-handler

A package to handle authentications across different applications

1.0.13
latest
npm
Version published
Maintainers
1
Created
Source

jup-auth-handler

jup-auth-handler is a promise-based Node.js auth handler for MySQL using ORM Sequelize. Provides basic auth functions

Installation

$ npm i jup-auth-handler --save

Usage

You can use both ES6 or ES5 syntax to use the package

$ import { auth, userControllers, runMigrations } from 'jup-auth-handler' //es6 syntax
// Or you can use es5 Syntax
$ const { auth, userControllers, runMigrations } = require('jup-auth-handler'); //es5 syntax

// in your main.js use following to run all the migrations once the server gets started
runMigrations();

// for ACL use
app.use(auth.setAccessControl()); // will protect routes as per permissions

// using for login
app.post('/login', auth.authenticateUser, userControllers.createUser);

//using for protected routes
app.post('/protected-route', auth.verifyUser, yourController)

Create a .env file in the root directory of your project. Add environment-specific variables on new lines in the form of NAME=VALUE. and load it in Node enviroment

Required ENV variables

#update the variables values with actual ones
MYSQL_USER=root
MYSQL_PASSWORD=root
MYSQL_DATABASE=jupiter
MYSQL_HOST=local
MYSQL_PORT=3606
expiry_time = 36000 # jwt token expiry time in miliseconds
SECRET_KEY_JWT = xyz #your secret JWT key
NO_REPLY_EMAIL = adnanshuja3@gmail.com # your email
NO_REPLY_PASSWORD = yourpassword #to send email to user [password reset, signup etc]

Tests

$ npm run test // run tests in package directory

Keywords

mysql

FAQs

Package last updated on 02 Sep 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts