pusudb-use-auth-jwt
Middleware to authenticate the pusudb.
This middleware implements authentication with jsonwebtoken.
Framework: https://www.npmjs.com/package/pusudb
Installing
npm install pusudb-use-auth-jwt --save
Use
Create the auth-instance and define the options. The user can be accessed with req.user in other middlewares.
var Pusudb = var pusudb = 3000 'localhost' log : true var AuthJwt = /** * Default options { * login: '/login', * logout: '/logout', * signin: '/signin', * signinActive: true, * redirect: '/index', * redirectActive: false, * cookie : 'bearer', // cookie key * cookieOptions : { maxAge : 365 * 86400 } // see npm cookies for other options * secret : 'my-token-secret', // default a unique-string * db: './users', // define './other-db' or __dirname + '/pathToDb/users' * form: { password : 'password', name : 'email' }, * expire: '1y', // json webtoken expires in * assignUser: false // assign key and userName to req.docs to handle it in the response * } */ var authjwt = /* options */ // Add some routes which needs authentication ( string || array )authauth auth //add the middleware to the pusudbpusudb //add the middleware to the pusudb for websocket-authenticationpusudb pusudb
HTML
POST the userdata to the pusudb. The names of the form-input-fields are defined in option form. The action are defined in options login, logout and signin.
WebSocket
Emit a login, logout, signin or token package to the pusudb.
// Loginws;// Logoutws;// Signinws;// Tokenws
Authors
- Yannick Grund - Initial work - yamigr
License
This project is licensed under the MIT License