1.0.21 • Published 4 years ago

libidentity v1.0.21

Weekly downloads
-
License
ISC
Repository
-
Last release
4 years ago

Identity Library for App Cloud Platform

This is the library to use security and identity service within the ACP platform.

Installation

Initialize the Security Context

const AppSettings = require(`Your AppSettings File Location`);
const config = new AppSettings();

var SecurityContext = require('libidentity');
const securityContext = new SecurityContext(config);

// Available middlewares sequence
🡣 securityContext.verifyToken
 🡣 securityContext.dbContextAccessor
  🡣 securityContext.verifyUser
   🡣 securityContext.verifyAdmin

Usage

// Configuration file

const fs = require('fs');
function AppSettings() {

    const PUB_KEY = fs.readFileSync(__dirname + '/public-key.pem', 'utf8');

    this.secretKey = PUB_KEY;

    this.mongoTenants = '***';
    this.redisHost = "***";
    this.redisPass = "***",
    this.rabbitMqConnection = "***";
    this.mongoDb = (dbName) => {
        return `mongodb://host:port/${dbName}`;
    }
};
module.exports = AppSettings;
// Express router
router.all('*', securityContext.verifyToken, securityContext.dbContextAccessor, securityContext.verifyUser)
  .post('/action', function(req, res, next) {
    // req object is propagated through all the middlewares above to ensure security
    // Some action goes here
  })
});
// ACP has support for socket.io also
// Middleware for socket.io connection

securityContext.verifySocketToken

const io = socketio(server);
io.on('connection', (socket) => {
  securityContext.verifySocketToken(socket, (sc) => { ... });
});

License

MIT

1.0.21

4 years ago

1.0.20

4 years ago

1.0.19

4 years ago

1.0.18

4 years ago

1.0.17

4 years ago

1.0.16

4 years ago

1.0.15

4 years ago

1.0.14

4 years ago

1.0.13

4 years ago

1.0.12

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago