diff --git a/lib/ponte.js b/lib/ponte.js index 675c9eb..f63018d 100644 --- a/lib/ponte.js +++ b/lib/ponte.js @@ -43,6 +43,8 @@ function Ponte(opts, done) { }, function(err) { if (done) { done(err, that); + } else if(err) { + console.log("Ponte Server setting " + err ); } }); } diff --git a/lib/servers.js b/lib/servers.js index fea446b..b69fef0 100644 --- a/lib/servers.js +++ b/lib/servers.js @@ -41,6 +41,22 @@ module.exports = [{ service: "MQTT" }); var server = new mosca.Server(opts, cb); + // example server opts for Auth0 and secure + // mqtt: { + // port: 6001, // tcp but overrided by secure port number following + // secure: { + // port: 8443, // override the default and non-secure port setting + // keyPath: SECURE_KEY, // TLS key path + // certPath: SECURE_CERT, // TLS Cert path + // authMethod: auth0, // sample of the auth0 functions from package auth0mosca + // }, + // } + if( opts.secure ) { + if( opts.secure.authMethod.constructor.name === "Auth0Mosca" ) { + server.authenticate = opts.secure.authMethod.authenticateWithCredentials(); + server.authorizePublish = opts.secure.authMethod.authorizePublish(); + server.authorizeSubscribe = opts.secure.authMethod.authorizeSubscribe(); + } server.on('published', function moscaPonteEvent(packet) { opts.ponte.emit('updated', packet.topic, packet.payload); });