New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details
Socket
Book a DemoSign in
Socket

ws-basic-auth-express

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ws-basic-auth-express

Adds basic auth to socket connections in express

latest
Source
npmnpm
Version
0.0.1
Version published
Maintainers
1
Created
Source

Overview

Adds basic auth to socket connections in express. Only tested with ws. Socket.io is not supported.

Example

var express = require('express');
var wsBasicAuth = require("ws-basic-auth-express");
var http = require('http');
var WebSocketServer = require('ws').Server

var app = express();
var server = http.createServer(app);
var wss = new WebSocketServer({server: server});

var wsAuth = wsBasicAuth(function(username, password) {
  return username === process.env.USERNAME && password === process.env.PASSWORD;
});

#All upgrade requests go through auth
server.on('upgrade', wsAuth);

Credits

The basic auth code was borrowed from basic-auth-connect

The connection abort code was borrowed from ws.

Keywords

express

FAQs

Package last updated on 29 May 2014

Did you know?

Socket

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.

Install

Related posts