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
4982f211
Commit
4982f211
authored
Jun 28, 2018
by
Chavee Issariyapat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update authhook
parent
ce0624cf
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
10 deletions
+9
-10
authhook/auth_on_publish.js
+3
-4
authhook/auth_on_register.js
+2
-1
authhook/auth_on_subscribe.js
+4
-5
No files found.
authhook/auth_on_publish.js
View file @
4982f211
...
...
@@ -14,14 +14,12 @@ function authCheck(client_id, username, topic, callback) {
module
.
exports
=
function
(
options
=
{})
{
return
function
(
req
,
res
,
next
)
{
if
(
req
.
header
(
'vernemq-hook'
)
==
'auth_on_publish'
)
{
if
(
req
.
header
(
'vernemq-hook'
)
==
'auth_on_publish'
&&
req
&&
req
.
body
)
{
if
(
options
.
debug
)
{
console
.
log
(
req
.
body
);
}
var
out
,
authstatus
;
var
cachekey
=
req
.
body
.
client_id
+
':'
+
req
.
body
.
username
+
':'
+
req
.
body
.
password
;
var
authstatus
;
var
topic
=
req
.
body
.
topic
;
var
cachekey
=
'pub:'
+
req
.
body
.
client_id
+
':'
+
req
.
body
.
username
+
':'
+
topic
;
...
...
@@ -47,6 +45,7 @@ module.exports = function(options={}) {
res
.
send
({
"result"
:
"no"
});
next
();
}
}
}
authhook/auth_on_register.js
View file @
4982f211
...
...
@@ -11,8 +11,8 @@ var authclient = require('seneca')({log: 'silent'})
// for testing
function
authCheck
(
client_id
,
token
,
password
,
callback
)
{
authclient
.
act
({
role
:
'auth'
,
cmd
:
'token'
,
action
:
'info'
,
token
:
token
},
function
(
err
,
res
)
{
console
.
log
(
res
);
if
(
res
&&
res
.
data
)
{
callback
(
true
);
}
...
...
@@ -48,6 +48,7 @@ module.exports = function(options={}) {
res
.
send
({
"result"
:
"no"
});
next
();
}
}
}
authhook/auth_on_subscribe.js
View file @
4982f211
...
...
@@ -7,21 +7,19 @@ var LRU = require("lru-cache") ,
});
// for testing
function
authCheck
(
client_id
,
username
,
topic
,
callback
)
{
function
authCheck
(
client_id
,
token
,
topic
,
callback
)
{
callback
(
true
);
}
module
.
exports
=
function
(
options
=
{})
{
return
function
(
req
,
res
,
next
)
{
if
(
req
.
header
(
'vernemq-hook'
)
==
'auth_on_
publish'
)
{
if
(
req
.
header
(
'vernemq-hook'
)
==
'auth_on_
subscribe'
&&
req
&&
req
.
body
)
{
if
(
options
.
debug
)
{
console
.
log
(
req
.
body
);
}
var
out
,
authstatus
;
var
cachekey
=
req
.
body
.
client_id
+
':'
+
req
.
body
.
username
+
':'
+
req
.
body
.
password
;
var
authstatus
;
var
topic
=
req
.
body
.
topic
;
var
cachekey
=
'sub:'
+
req
.
body
.
client_id
+
':'
+
req
.
body
.
username
+
':'
+
topic
;
...
...
@@ -47,6 +45,7 @@ module.exports = function(options={}) {
res
.
send
({
"result"
:
"no"
});
next
();
}
}
}
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