Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
V
vernemq
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
stack
vernemq
Commits
49e56b22
Commit
49e56b22
authored
Oct 24, 2018
by
zCaesar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
chg pth to tokenregistry
parent
6667b003
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
19 deletions
+21
-19
authhook/auth_on_publish.js
+1
-8
authhook/auth_on_register.js
+18
-5
authhook/auth_on_subscribe.js
+1
-5
authhook/on_unsubscribe.js
+1
-1
No files found.
authhook/auth_on_publish.js
View file @
49e56b22
...
...
@@ -27,14 +27,7 @@ module.exports = function (options = {}) {
var
response
var
decoded
=
require
(
'jwt-verify'
).
verify
(
req
.
body
.
username
).
res
// var decoded = require('./checkClientRole').checkRealDB(req.body.username)
// const util = require('util')
// console.log('-----------decode----------')
// console.log(util.inspect(decoded, false, null, true));
// console.log('-----------decode----------')
// console.log('-----------decodes----------')
// console.log(util.inspect(decodeds, false, null, true));
// console.log('-----------decodes----------')
if
(
decoded
)
{
if
(
decoded
.
role
===
'realtimedb'
)
response
=
{
'result'
:
'ok'
}
else
response
=
{
'result'
:
'no'
}
...
...
authhook/auth_on_register.js
View file @
49e56b22
var
validator
=
require
(
'./validator'
);
var
config
=
require
(
'config'
);
var
seneca
=
require
(
'seneca'
)({
log
:
'silent'
}).
client
({
port
:
config
.
get
(
'device_registry_port'
),
host
:
config
.
get
(
'device_registry_host'
)
});
// var seneca = require('seneca')({log: 'silent'}).client({ port: config.get('device_registry_port'), host: config.get('device_registry_host') });
var
seneca
=
require
(
'seneca'
)({
log
:
'silent'
}).
client
({
port
:
config
.
get
(
'token_registry_port'
),
host
:
config
.
get
(
'token_registry_host'
)
});
// https://github.com/isaacs/node-lru-cache
var
LRU
=
require
(
"lru-cache"
),
...
...
@@ -20,13 +21,11 @@ function authCheck(client_id, token, password, callback) {
if
(
require
(
'jwt-verify'
).
verify
(
token
))
{
// auth realtimedb by token
callback
(
true
);
}
// if (require('./checkClientRole').checkRealDB(token)) { // auth realtimedb by token
// callback(true);
// }
else
{
if
(
require
(
'jwt-verify'
).
verify
(
token
))
callback
(
true
)
// auth client device by token
else
{
seneca
.
act
(
'
cmd:getAccessTokenInfo
, tokencode:'
+
token
,
function
(
err
,
res
)
{
seneca
.
act
(
'
ms:tokenregistry, cmd:getAttributes, type:device
, tokencode:'
+
token
,
function
(
err
,
res
)
{
if
(
!
err
&&
res
)
{
var
token_profile
=
(
res
&&
res
.
result
&&
res
.
result
[
0
])?
res
.
result
[
0
]:{};
var
mqttauth
=
{
...
...
@@ -40,6 +39,20 @@ function authCheck(client_id, token, password, callback) {
callback
(
false
);
}
});
// seneca.act('cmd:getAccessTokenInfo, tokencode:'+token, function(err,res) {
// if (!err && res) {
// var token_profile = (res&&res.result&&res.result[0])?res.result[0]:{};
// var mqttauth = {
// clientid : client_id,
// token : token,
// password : password
// };
// callback( validator.auth_connect(mqttauth, token_profile) );
// }
// else {
// callback(false);
// }
// });
// authclient.act({ role: 'auth', cmd: 'token', action: 'info', token: token }, function (err, res) { // auth client device by query from db
...
...
authhook/auth_on_subscribe.js
View file @
49e56b22
...
...
@@ -26,11 +26,7 @@ module.exports = function (options = {}) {
}
var
response
var
decoded
=
require
(
'jwt-verify'
).
verify
(
req
.
body
.
username
).
res
// var decoded = require('./checkClientRole').checkRealDB(req.body.username)
const
util
=
require
(
'util'
)
console
.
log
(
'-----------decode----------'
)
console
.
log
(
util
.
inspect
(
decoded
,
false
,
null
,
true
));
console
.
log
(
'-----------decode----------'
)
if
(
decoded
)
{
if
(
decoded
.
role
===
'realtimedb'
)
response
=
{
'result'
:
'ok'
}
else
response
=
{
'result'
:
'no'
}
...
...
authhook/on_unsubscribe.js
View file @
49e56b22
...
...
@@ -8,7 +8,7 @@ module.exports = function(options = {}) {
var
response
var
decoded
=
require
(
'jwt-verify'
).
verify
(
token
).
res
// var decoded = require('./checkClientRole').checkRealDB(token)
if
(
decoded
)
{
if
(
decoded
.
role
===
'realtimedb'
)
{
response
=
{
'result'
:
'ok'
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment