1.0.21 • Published 3 years ago

libidentity v1.0.21

Weekly downloads
-
License
ISC
Repository
-
Last release
3 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

3 years ago

1.0.20

3 years ago

1.0.19

3 years ago

1.0.18

3 years ago

1.0.17

3 years ago

1.0.16

3 years ago

1.0.15

3 years ago

1.0.14

3 years ago

1.0.13

3 years ago

1.0.12

3 years ago

1.0.11

3 years ago

1.0.10

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago