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
69c2caad
Commit
69c2caad
authored
Oct 11, 2018
by
Chavee Issariyapat
Browse files
Options
Browse Files
Download
Plain Diff
merge from master
parents
7ac5ed06
a6ab5fd5
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
23 additions
and
24 deletions
+23
-24
authhook/.gitignore
+1
-0
authhook/auth_on_publish.js
+1
-7
authhook/auth_on_subscribe.js
+1
-1
authhook/config/custom-environment-variables.json
+8
-1
authhook/index.js
+8
-8
authhook/on_deliver.js
+0
-0
authhook/on_unsubscribe.js
+1
-1
authhook/test/getTopicTest.js
+1
-1
authhook/utils/router.js
+2
-5
No files found.
authhook/.gitignore
View file @
69c2caad
.DS_Store
.DS_Store
node_modules/
node_modules/
config/*.json
authhook/auth_on_publish.js
View file @
69c2caad
...
@@ -6,11 +6,6 @@ var LRU = require("lru-cache"),
...
@@ -6,11 +6,6 @@ var LRU = require("lru-cache"),
maxAge
:
1000
*
60
*
5
maxAge
:
1000
*
60
*
5
});
});
// for testing
// function authCheck(client_id, username, topic, callback) {
// callback(true);
// }
module
.
exports
=
function
(
options
=
{})
{
module
.
exports
=
function
(
options
=
{})
{
return
function
(
req
,
res
,
next
)
{
return
function
(
req
,
res
,
next
)
{
...
@@ -43,8 +38,7 @@ module.exports = function (options = {}) {
...
@@ -43,8 +38,7 @@ module.exports = function (options = {}) {
var
output
=
{};
var
output
=
{};
GGID
.
getGroupID
(
req
.
body
.
username
,
req
.
body
.
client_id
,
function
(
group
)
{
GGID
.
getGroupID
(
req
.
body
.
username
,
req
.
body
.
client_id
,
function
(
group
)
{
var
_ftopic
=
require
(
'./utils/router'
).
rewriteTopic
(
topic
,
'pub'
,
group
,
req
.
body
.
client_id
,
output
);
// get topic where concat with groupID
var
_ftopic
=
require
(
'./utils/getTopic'
).
rewriteTopic
(
topic
,
'pub'
,
group
,
req
.
body
.
client_id
,
output
);
// get topic where concat with groupID
response
=
{
response
=
{
'result'
:
'ok'
,
'result'
:
'ok'
,
'modifiers'
:
{
'modifiers'
:
{
...
...
authhook/auth_on_subscribe.js
View file @
69c2caad
...
@@ -38,7 +38,7 @@ module.exports = function (options = {}) {
...
@@ -38,7 +38,7 @@ module.exports = function (options = {}) {
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
);
console
.
log
(
group
);
var
_ftopic
=
require
(
'./utils/
getTopic
'
).
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
,
'qos'
:
0
'qos'
:
0
...
...
authhook/config/custom-environment-variables.json
View file @
69c2caad
...
@@ -3,5 +3,12 @@
...
@@ -3,5 +3,12 @@
"authserv_port"
:
"AUTH_SERVICE_PORT"
,
"authserv_port"
:
"AUTH_SERVICE_PORT"
,
"device_registry_host"
:
"DEVICE_REGISTRY_HOST"
,
"device_registry_host"
:
"DEVICE_REGISTRY_HOST"
,
"device_registry_port"
:
"DEVICE_REGISTRY_PORT"
"device_registry_port"
:
"DEVICE_REGISTRY_PORT"
,
"auth_on_register_debug"
:
"AUTH_ON_REGISTER_DEBUG"
,
"auth_on_publish_debug"
:
"AUTH_ON_PUBLISH_DEBUG"
,
"auth_on_subscribe_debug"
:
"AUTH_ON_SUBSCRIBE_DEBUG"
,
"on_publish_debug"
:
"ON_PUBLISH_DEBUG"
,
"on_deliver_debug"
:
"ON_DELIVER_DEBUG"
,
"on_unsubscribe_debug"
:
"ON_UNSUBSCRIBE_DEBUG"
}
}
authhook/index.js
View file @
69c2caad
process
.
env
[
"NODE_ENV"
]
=
"development"
;
process
.
env
[
"NODE_CONFIG_DIR"
]
=
__dirname
+
"/config/"
;
process
.
env
[
"NODE_CONFIG_DIR"
]
=
__dirname
+
"/config/"
;
var
config
=
require
(
'config'
);
var
auth_on_register_debug
=
process
.
env
[
"AUTH_ON_REGISTER_DEBUG"
]
||
false
;
var
auth_on_publish_debug
=
process
.
env
[
"AUTH_ON_PUBLISH_DEBUG"
]
||
true
;
var
auth_on_register_debug
=
config
.
get
(
'auth_on_register_debug'
);
var
auth_on_subscribe_debug
=
process
.
env
[
"AUTH_ON_SUBSCRIBE_DEBUG"
]
||
true
;
var
auth_on_publish_debug
=
config
.
get
(
'auth_on_publish_debug'
);
var
on_publish_debug
=
process
.
env
[
"ON_PUBLISH_DEBUG"
]
||
true
;
var
auth_on_subscribe_debug
=
config
.
get
(
'auth_on_subscribe_debug'
);
var
on_deliver_debug
=
process
.
env
[
"ON_DELIVER_DEBUG"
]
||
true
;
var
on_publish_debug
=
config
.
get
(
'on_publish_debug'
);
var
on_unsubscribe_debug
=
process
.
env
[
"ON_UNSUBSCRIBE_DEBUG"
]
||
true
;
var
on_deliver_debug
=
config
.
get
(
'on_deliver_debug'
);
var
on_unsubscribe_debug
=
config
.
get
(
'on_unsubscribe_debug'
);
var
restify
=
require
(
'restify'
);
var
restify
=
require
(
'restify'
);
var
auth_on_register
=
require
(
'./auth_on_register'
)({
debug
:
auth_on_register_debug
});
var
auth_on_register
=
require
(
'./auth_on_register'
)({
debug
:
auth_on_register_debug
});
...
...
authhook/on_deliver.js
View file @
69c2caad
authhook/on_unsubscribe.js
View file @
69c2caad
...
@@ -21,7 +21,7 @@ module.exports = function(options = {}) {
...
@@ -21,7 +21,7 @@ module.exports = function(options = {}) {
GGID
.
getGroupID
(
token
,
client_id
,
function
(
group
)
{
GGID
.
getGroupID
(
token
,
client_id
,
function
(
group
)
{
if
(
group
)
{
if
(
group
)
{
var
_ftopic
=
require
(
'./utils/
getTopic
'
).
rewriteTopic
(
topic
,
'unsub'
,
group
,
client_id
)
var
_ftopic
=
require
(
'./utils/
router
'
).
rewriteTopic
(
topic
,
'unsub'
,
group
,
client_id
)
response
=
{
response
=
{
"result"
:
"ok"
,
"result"
:
"ok"
,
"topics"
:
[
_ftopic
]
"topics"
:
[
_ftopic
]
...
...
authhook/test/getTopicTest.js
View file @
69c2caad
var
assert
=
require
(
'assert'
)
var
assert
=
require
(
'assert'
)
var
getTopic
=
require
(
'../utils/
getTopic'
).
get
Topic
var
getTopic
=
require
(
'../utils/
router'
).
rewrite
Topic
describe
(
'GetTopic'
,
()
=>
{
describe
(
'GetTopic'
,
()
=>
{
describe
(
'realtime msg'
,
()
=>
{
describe
(
'realtime msg'
,
()
=>
{
...
...
authhook/utils/
getTopic
.js
→
authhook/utils/
router
.js
View file @
69c2caad
...
@@ -2,19 +2,16 @@ var modify = require('./modify');
...
@@ -2,19 +2,16 @@ var modify = require('./modify');
function
rewriteTopic
(
topic
,
op
,
groupid
,
clientid
,
output
)
{
function
rewriteTopic
(
topic
,
op
,
groupid
,
clientid
,
output
)
{
var
chunk
=
topic
.
split
(
'/'
);
var
chunk
=
topic
.
split
(
'/'
);
console
.
log
(
groupid
);
switch
(
chunk
[
0
])
{
switch
(
chunk
[
0
])
{
case
'@msg'
:
case
'@msg'
:
return
modify
.
insertWordIntoTopic
(
topic
,
'!'
+
groupid
,
1
);
return
modify
.
insertWordIntoTopic
(
topic
,
'!'
+
groupid
,
1
);
case
'@shadow'
:
case
'@shadow'
:
if
(
chunk
[
1
]
==
'
write'
||
chunk
[
1
]
==
'read
'
)
{
if
(
chunk
[
1
]
==
'
set'
||
chunk
[
1
]
==
'get
'
)
{
output
.
verb
=
chunk
[
1
];
output
.
verb
=
chunk
[
1
];
return
modify
.
insertWordIntoTopic
(
topic
,
''
+
clientid
,
2
);
return
modify
.
insertWordIntoTopic
(
topic
,
''
+
clientid
,
2
);
}
}
else
if
(
chunk
[
1
]
==
'
set'
||
chunk
[
1
]
==
'get
'
)
{
else
if
(
chunk
[
1
]
==
'
write'
||
chunk
[
1
]
==
'read
'
)
{
output
.
verb
=
chunk
[
1
];
output
.
verb
=
chunk
[
1
];
return
modify
.
insertWordIntoTopic
(
topic
,
groupid
,
2
);
return
modify
.
insertWordIntoTopic
(
topic
,
groupid
,
2
);
}
}
...
...
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