From 9814e75dadbb9d2eaf3761179808a840da752279 Mon Sep 17 00:00:00 2001 From: Anatoly Tsapkov Date: Thu, 11 Apr 2019 22:58:39 -0400 Subject: [PATCH] authorize function --- README.md | 3 +++ lib/fox_api.js | 1 + lib/mqtt/gate.js | 5 ++++- package-lock.json | 14 +++++++------- package.json | 6 +++--- 5 files changed, 18 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index 3dd62f1..541de27 100644 --- a/README.md +++ b/README.md @@ -147,6 +147,9 @@ publish('the.key', [ 'args' ], { kwArgs: false }, { Take a look for more use cases at http://jeta.host/ ## Changes: +2019-04-11 +- authorize function supported for SUBSCRIBE & PUBLISH + 2019-03-22 - WAMP registration option.concurrency supported. diff --git a/lib/fox_api.js b/lib/fox_api.js index 560f3ca..8badb42 100644 --- a/lib/fox_api.js +++ b/lib/fox_api.js @@ -6,6 +6,7 @@ const Session = require('./session') const tools = require('./tools') function FoxApi (realm) { + this.registerSession = () => {} Session.call(this, this) this.sessionId = tools.randomId() diff --git a/lib/mqtt/gate.js b/lib/mqtt/gate.js index 3f5eba3..b056b77 100644 --- a/lib/mqtt/gate.js +++ b/lib/mqtt/gate.js @@ -161,9 +161,12 @@ handlers.publish = function (ctx, session, message) { data = { payload: message.payload } } + let uri = mqttParse(message.topic) + this.checkAuthorize(ctx, 'publish', uri) + session.realm.doPush(session, { mtype: 'publish', - uri: mqttParse(message.topic), + uri, data, opt }) diff --git a/package-lock.json b/package-lock.json index 2644d3a..788e6db 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "fox-wamp", - "version": "0.6.1", + "version": "0.6.2", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -254,9 +254,9 @@ "dev": true }, "commander": { - "version": "2.19.0", - "resolved": "https://registry.npmjs.org/commander/-/commander-2.19.0.tgz", - "integrity": "sha512-6tvAOO+D6OENvRAh524Dh9jcfKTYDQAqvqezbCW82xj5X0pSrcpxtvRKHLG0yBY6SD7PSDrJaj+0AiOcKVd1Xg==" + "version": "2.20.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.20.0.tgz", + "integrity": "sha512-7j2y+40w61zy6YC2iRNpUe/NwhNyoXrYpHMrSunaMG64nRnaf96zO/KMQR4OyN/UnE5KLyEBnKHd4aG3rskjpQ==" }, "concat-map": { "version": "0.0.1", @@ -936,9 +936,9 @@ "dev": true }, "qlobber": { - "version": "3.0.2", - "resolved": "https://registry.npmjs.org/qlobber/-/qlobber-3.0.2.tgz", - "integrity": "sha512-WSBRhZqAgVpdq6nypgMUWjlvfCgc6lUIEENy6dwg60tN2sJBN5vFyADGNaSujYeZOepFPB1uFzgBAlK+L0RKVA==" + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/qlobber/-/qlobber-3.1.0.tgz", + "integrity": "sha512-B7EU6Hv9g4BeJiB7qtOjn9wwgqVpcWE5c4/86O0Yoj7fmAvgwXrdG1E+QF13S/+TX5XGUl7toizP0gzXR2Saug==" }, "ramda": { "version": "0.26.1", diff --git a/package.json b/package.json index 32b715a..887424f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "fox-wamp", - "version": "0.6.1", + "version": "0.6.2", "description": "Web Application Message Router/Server WAMP/MQTT", "author": { "name": "Anatoly Tsapkov", @@ -22,11 +22,11 @@ "subscribe" ], "dependencies": { - "commander": "^2.19.0", + "commander": "^2.20.0", "jsonschema": "^1.2.4", "mqtt-packet": "^6.1.1", "node-statsd": "*", - "qlobber": "*", + "qlobber": "^3.1.0", "ws": "^6.2.1" }, "devDependencies": {