Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
use-express-middleware
Advanced tools
The main purpose of this module is to use express
middleware for
authentication in deepstream.io
.
If you find other uses for this module, please let me know.
npm install use-express-middleware --save
✓ express-session
✓ passport.initialize()
✓ passport.session()
import Deepstream from 'deepstream.io'
import useExpressMiddleware from 'use-express-middleware'
import expressSession from 'express-session'
import passport from 'passport'
const server = new Deepstream()
// You can define this somewhere in your app and then import it both
// for express and deepstream.
// If you use a store such as redis for you sessions, you'll be able
// to run express and deepstream in two seperate processes and/or on
// two seperate ports if you so please.
const session = expressSession({
...options
})
const middleware = [session, passport.initialize(), passport.session()]
// Using a callback:
server.set('permissionHandler', {
isValidUser(connectionData, authData, callback) {
useExpressMiddleware(connectionData.headers, middleware, (req, res) => {
if(req.user) {
callback(null, req.user.id)
} else {
callback(null, 'open')
}
})
},
canPerformAction(id, message, callback) {
const user = getUserFromId(id) // pseudo code
callback(null, user.isAdmin)
}
})
// Using promises and async/await:
server.set('permissionHandler', {
isValidUser: async (connectionData, authData, callback) => {
const {req, res} = await useExpressMiddleware(connectionData.headers, middleware)
if(req.user) {
callback(null, req.user.id)
} else {
callback(null, 'open')
}
},
...
})
FAQs
Use express middleware outside of express.
We found that use-express-middleware demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.