1.1.7 • Published 7 years ago

shieldjs v1.1.7

Weekly downloads
4
License
ISC
Repository
github
Last release
7 years ago

How ShieldJS Works?

The library contains two security parts:

  1. 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.
  2. Auth Routes - shieldJS will create the standard auth2 authentication routes for you.

What do I have to do?

  1. Choose your auth2 provider. For now, we only support auth0 provider (https://www.auth0.com), and register.
  2. Install ShieldJS.
  3. Use ShieldJS as middleware.
  4. Initialize ShieldJS with your provider's application data.
  5. 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:

  1. /auth/login
  2. /auth/logout
  3. /auth/callback
  4. /auth/logoutcallback
1.1.7

7 years ago

1.1.6

7 years ago

1.1.5

7 years ago

1.1.4

7 years ago

1.1.3

7 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago