New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

shieldjs

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

shieldjs

Easy implementation for auth2 authentication to secure your server, based on passportjs. First including JWT middleware to handle auth2 access token, and also automatic creation of authentication routes for each required strategy.

latest
Source
npmnpm
Version
1.1.7
Version published
Maintainers
1
Created
Source

--- # What is ShieldJS #### ShieldJS makes it easier than ever to secure your server with auth2 and jwt. ###### Currently, we only support auth0 () as auth2 provider. You are welcome to commit another provider's support to our library :)

How ShieldJS Works?

The library contains two security parts:

  • JWT Middleware - By using ShieldJS, your server routes will be totally secured by JWT (JSON Web Token). This middleware will look for a bearer token in the request header, and if not found will look for it in the cookie.
  • Auth Routes - shieldJS will create the standard auth2 authentication routes for you.

What do I have to do?

  • Choose your auth2 provider. For now, we only support auth0 provider (https://www.auth0.com), and register.
  • Install ShieldJS.
  • Use ShieldJS as middleware.
  • Initialize ShieldJS with your provider's application data.
  • Be Secured :)

How to implement?

Install ShieldJS from npm:

$ npm install --save shieldjs

Require ShieldJS, and use it as middleware for your app:


const express = require('express');
const shield = require("shieldjs");

const app = express();

// Will be used as JWT Middleware
app.use(shield.jwt(
    {
        excludeRoutes: ['/abc'],
    	domain: AUTH0.DOMAIN,
    	client_id: AUTH0.CLIENT_ID,
    	secret: AUTH0.CLIENT_SECRET
    }
));

// Will create routes for authentication
app.use(shield.authRoutes({
    authRoute: '/auth',
    provider: 'auth0',
    credentials:{
        domain: AUTH0.DOMAIN,
        client_id: AUTH0.CLIENT_ID,
        secret: AUTH0.CLIENT_SECRET,
        callback_url: AUTH0.CALLBACK_URL
    }
}))

If authRoute will not be provided, not authentication routes will be created!

Authentication routes will be created in this example:

  • /auth/login
  • /auth/logout
  • /auth/callback
  • /auth/logoutcallback

FAQs

Package last updated on 02 Feb 2017

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