2.0.1 • Published 4 years ago

@moreillon/socketio_authentication_middleware v2.0.1

Weekly downloads
-
License
-
Repository
-
Last release
4 years ago

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}`) })
2.0.1

4 years ago

2.0.0

4 years ago

1.0.1

5 years ago

0.0.1

5 years ago