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
e0d42e97
Commit
e0d42e97
authored
Oct 29, 2018
by
zCaesar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
edit register
parent
a0cc5f18
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
17 deletions
+20
-17
authhook/auth_on_register.js
+16
-12
authhook/auth_on_subscribe.js
+0
-1
authhook/config/local-dev.json
+2
-2
authhook/package-lock.json
+2
-2
No files found.
authhook/auth_on_register.js
View file @
e0d42e97
...
@@ -2,7 +2,7 @@ var validator = require('./validator');
...
@@ -2,7 +2,7 @@ var validator = require('./validator');
var
config
=
require
(
'config'
);
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'
)
});
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
// https://github.com/isaacs/node-lru-cache
var
LRU
=
require
(
"lru-cache"
),
var
LRU
=
require
(
"lru-cache"
),
...
@@ -17,23 +17,27 @@ var debug = false;
...
@@ -17,23 +17,27 @@ var debug = false;
function
authCheck
(
client_id
,
token
,
password
,
callback
)
{
function
authCheck
(
client_id
,
token
,
password
,
callback
)
{
const
util
=
require
(
'util'
)
// console.log(util.inspect(myObject, false, null, true));
if
(
require
(
'jwt-verify'
).
verify
(
token
))
{
// auth realtimedb by token
// console.log('jwt-result:' + util.inspect(require('jwt-verify').verify(token), false, null, true))
if
(
require
(
'jwt-verify'
).
verify
(
token
).
res
)
{
// auth realtimedb by token
callback
(
true
);
callback
(
true
);
}
}
else
{
else
{
if
(
require
(
'jwt-verify'
).
verify
(
token
))
callback
(
true
)
// auth client device by token
// console.log('token :' + token)
else
{
seneca
.
act
(
'ms:tokenregistry, cmd:getAttributes, type:device, tokencode:'
+
token
,
function
(
err
,
res
)
{
seneca
.
act
(
'ms:tokenregistry, cmd:getAttributes, type:device, tokencode:'
+
token
,
function
(
err
,
res
)
{
// console.log('result : ' + util.inspect(res.result, false, null, true))
if
(
!
err
&&
res
)
{
if
(
res
.
result
)
{
var
token_profile
=
(
res
&&
res
.
result
&&
res
.
result
[
0
])?
res
.
result
[
0
]:
{};
var
token_profile
=
(
res
&&
res
.
result
&&
res
.
result
[
0
])
?
res
.
result
[
0
]
:
{};
var
mqttauth
=
{
var
mqttauth
=
{
clientid
:
client_id
,
clientid
:
client_id
,
token
:
token
,
token
:
token
,
password
:
password
password
:
password
};
};
callback
(
validator
.
auth_connect
(
mqttauth
,
token_profile
)
);
callback
(
validator
.
auth_connect
(
mqttauth
,
token_profile
)
);
}
}
else
{
else
{
callback
(
false
);
callback
(
false
);
...
@@ -77,7 +81,7 @@ function authCheck(client_id, token, password, callback) {
...
@@ -77,7 +81,7 @@ function authCheck(client_id, token, password, callback) {
// callback(false);
// callback(false);
// }
// }
// });
// });
}
}
}
}
}
...
...
authhook/auth_on_subscribe.js
View file @
e0d42e97
...
@@ -37,7 +37,6 @@ module.exports = function (options = {}) {
...
@@ -37,7 +37,6 @@ module.exports = function (options = {}) {
var
GGID
=
require
(
'./utils/getGroupID'
);
var
GGID
=
require
(
'./utils/getGroupID'
);
GGID
.
getGroupID
(
req
.
body
.
username
,
req
.
body
.
client_id
,
function
(
group
)
{
GGID
.
getGroupID
(
req
.
body
.
username
,
req
.
body
.
client_id
,
function
(
group
)
{
console
.
log
(
group
);
var
_ftopic
=
require
(
'./utils/router'
).
rewriteTopic
(
topic
,
'sub'
,
group
,
req
.
body
.
client_id
)
// get topic where concat with groupID
var
_ftopic
=
require
(
'./utils/router'
).
rewriteTopic
(
topic
,
'sub'
,
group
,
req
.
body
.
client_id
)
// get topic where concat with groupID
var
_topic
=
[{
// setTopic for response
var
_topic
=
[{
// setTopic for response
'topic'
:
_ftopic
,
'topic'
:
_ftopic
,
...
...
authhook/config/local-dev.json
View file @
e0d42e97
{
{
"device_registry_host"
:
"
alpha.nexpie.io
"
,
"device_registry_host"
:
"
localhost
"
,
"device_registry_port"
:
8990
,
"device_registry_port"
:
8990
,
"token_registry_host"
:
"
alpha.nexpie.io
"
,
"token_registry_host"
:
"
localhost
"
,
"token_registry_port"
:
8790
,
"token_registry_port"
:
8790
,
"auth_on_register_debug"
:
true
,
"auth_on_register_debug"
:
true
,
...
...
authhook/package-lock.json
View file @
e0d42e97
...
@@ -438,8 +438,8 @@
...
@@ -438,8 +438,8 @@
}
}
},
},
"jwt-verify"
:
{
"jwt-verify"
:
{
"version"
:
"git+https://nexpienpm:CCqLQjg4ytvzN7QbssUV@dev.nexpie.com/npm/jwt-verify.git#
2652fe32eb15f1e1f05bc31aa98f5a7c10d049e3
"
,
"version"
:
"git+https://nexpienpm:CCqLQjg4ytvzN7QbssUV@dev.nexpie.com/npm/jwt-verify.git#
c9692da3fd11464e9270acd0c47f289648119ec9
"
,
"from"
:
"git+https://nexpienpm:CCqLQjg4ytvzN7QbssUV@dev.nexpie.com/npm/jwt-verify.git
#issuer
"
,
"from"
:
"git+https://nexpienpm:CCqLQjg4ytvzN7QbssUV@dev.nexpie.com/npm/jwt-verify.git"
,
"requires"
:
{
"requires"
:
{
"config"
:
"^2.0.1"
,
"config"
:
"^2.0.1"
,
"jsonwebtoken"
:
"^8.3.0"
"jsonwebtoken"
:
"^8.3.0"
...
...
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