1.0.0 • Published 8 years ago

seneca-mosca-auth v1.0.0

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

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