node package manager
Stop wasting time. Easily manage code sharing in your team. Create a free org »

seneca-mosca-auth

seneca-mosca-auth

npm version Build Status

Authentication and Authorization for Mosca using Seneca and Seneca User.

This is a specialization of Seneca User for this specific use case. Go there and have a look for the full docs. The default role is changed from 'user' to 'mosca-auth'.

Install

npm i mosca seneca-mosca-auth --save

Usage

'use strict'
 
const Mosca = require('mosca')
const Seneca = require('seneca')
const MoscaAuth = require('seneca-mosca-auth')
 
var seneca = Seneca()
seneca.use(MoscaAuth)
var server = new Mosca.Server()
 
// configures Mosca to authenticate via seneca 
MoscaAuth.setup(seneca, server)
 
// register a user 
seneca.act({
  role: 'mosca-auth',
  cmd: 'register',
  nick: 'mydevice',
  email: 'matteo.collina@nearform.com',
  password: 'mypassword',
  publishPatterns: ['hello', 'a/#', 'b/+'],
  subscribePatterns: ['hello', 'a/#', 'b/+']
})

## Acknowledgements

This project was kindly sponsored by nearForm.

License

MIT