wba

ws-basic-auth-express

Adds basic auth to socket connections in express

Showing:

Popularity

Downloads/wk

0

GitHub Stars

1

Maintenance

Last Commit

8yrs ago

Contributors

2

Package

Dependencies

0

License

MIT

Type Definitions

Tree-Shakeable

No?

Readme

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.

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100
No reviews found
Be the first to rate

Tutorials

No tutorials found
Add a tutorial