@moreillon/socketio_authentication_middleware

2.0.1 • Public • Published

Socket.io authentication middleware

A simple middleware to authenticate socket.io clients

Usage

const express = require('express')
const http = require('http')
const auth = require('@moreillon/socketio_authentication_middleware')
const { Server } = require("socket.io")

const port = 7000

const socketio_options = { cors: { origin: '*' } }

const app = express();
const server = http.createServer(app);
const io = new Server(server, socketio_options);


const auth_options = { url: 'https://api.authentication.example.com/v2/whoami' }
io.use( auth(auth_options))

io.on('connection', (socket) => { console.log('a user connected') })

server.listen(port, () => { console.log(`App listening on port ${port}`) })

Readme

Keywords

none

Package Sidebar

Install

npm i @moreillon/socketio_authentication_middleware

Weekly Downloads

1

Version

2.0.1

License

none

Unpacked Size

1.5 kB

Total Files

3

Last publish

Collaborators

  • moreillon