seneca-mosca-auth

1.0.0 • Public • Published

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

Dependencies (2)

Dev Dependencies (7)

Package Sidebar

Install

npm i seneca-mosca-auth

Weekly Downloads

0

Version

1.0.0

License

MIT

Last publish

Collaborators

  • matteo.collina