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
6667b003
Commit
6667b003
authored
Oct 24, 2018
by
zCaesar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
delete chk role file
parent
539268ab
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
0 additions
and
89 deletions
+0
-89
authhook/checkClientRole.js
+0
-45
authhook/index.js
+0
-2
authhook/utils/getDates.js
+0
-42
No files found.
authhook/checkClientRole.js
deleted
100644 → 0
View file @
539268ab
var
jwt
=
require
(
'jsonwebtoken'
)
var
config
=
require
(
'config'
)
var
getExp
=
require
(
'./utils/getDates'
).
getExp
module
.
exports
.
checkRealDB
=
checkRealDB
module
.
exports
.
getRole
=
getRole
module
.
exports
.
signRole
=
signRole
function
checkRealDB
(
token
)
{
const
verifyOptions
=
{
algorithms
:
[
'ES256'
]
};
try
{
return
jwt
.
verify
(
token
,
config
.
get
(
'pubca'
),
verifyOptions
)
}
catch
(
e
)
{
return
false
}
}
function
getRole
(
token
)
{
var
secret
=
'nexpie'
try
{
return
jwt
.
verify
(
token
,
secret
)
}
catch
(
e
)
{
return
false
}
}
function
signRole
(
req
,
res
)
{
var
secret
=
'nexpie'
if
(
req
.
body
.
scope
&&
req
.
body
.
exp
)
{
const
signOptions
=
{
expiresIn
:
getExp
(
req
.
body
.
exp
)
}
var
payload
=
req
.
body
delete
payload
[
'exp'
]
res
.
send
(
jwt
.
sign
(
payload
,
secret
,
signOptions
))
}
else
{
res
.
send
(
'role not complete'
)
}
}
\ No newline at end of file
authhook/index.js
View file @
6667b003
...
@@ -15,7 +15,6 @@ var auth_on_subscribe = require('./auth_on_subscribe')({ debug: auth_on_subscrib
...
@@ -15,7 +15,6 @@ var auth_on_subscribe = require('./auth_on_subscribe')({ debug: auth_on_subscrib
var
on_publish
=
require
(
'./on_publish'
)({
debug
:
on_publish_debug
});
var
on_publish
=
require
(
'./on_publish'
)({
debug
:
on_publish_debug
});
var
on_deliver
=
require
(
'./on_deliver'
)({
debug
:
on_deliver_debug
});
var
on_deliver
=
require
(
'./on_deliver'
)({
debug
:
on_deliver_debug
});
var
on_unsubscribe
=
require
(
'./on_unsubscribe'
)({
debug
:
on_unsubscribe_debug
});
var
on_unsubscribe
=
require
(
'./on_unsubscribe'
)({
debug
:
on_unsubscribe_debug
});
var
signRole
=
require
(
'./checkClientRole'
).
signRole
const
server
=
restify
.
createServer
({
const
server
=
restify
.
createServer
({
name
:
'authhook'
,
name
:
'authhook'
,
...
@@ -45,7 +44,6 @@ server.post('/onsub', (req,res,next) => {
...
@@ -45,7 +44,6 @@ server.post('/onsub', (req,res,next) => {
server
.
post
(
'/onunsub'
,
on_unsubscribe
)
server
.
post
(
'/onunsub'
,
on_unsubscribe
)
server
.
post
(
'/ondeliver'
,
on_deliver
)
server
.
post
(
'/ondeliver'
,
on_deliver
)
server
.
post
(
'/onpub'
,
on_publish
)
server
.
post
(
'/onpub'
,
on_publish
)
server
.
post
(
'/signRole'
,
signRole
)
server
.
listen
(
port
,
function
()
{
server
.
listen
(
port
,
function
()
{
console
.
log
(
'%s listening at %s'
,
server
.
name
,
server
.
url
);
console
.
log
(
'%s listening at %s'
,
server
.
name
,
server
.
url
);
...
...
authhook/utils/getDates.js
deleted
100644 → 0
View file @
539268ab
module
.
exports
.
getExp
=
getExp
function
getExp
(
expires
)
{
var
exp
if
(
expires
.
endsWith
(
'y'
))
{
exp
=
getYears
(
expires
.
split
(
'y'
)[
0
])
}
else
if
(
expires
.
endsWith
(
'm'
))
{
exp
=
getMonths
(
expires
.
split
(
'm'
)[
0
])
}
else
if
(
expires
.
endsWith
(
'd'
))
{
exp
=
expires
.
split
(
'd'
)[
0
]
+
'd'
}
else
if
(
expires
.
endsWith
(
'h'
))
{
exp
=
expires
.
split
(
'h'
)[
0
]
+
'h'
}
else
if
(
expires
.
endsWith
(
'mi'
))
{
exp
=
getMinutes
(
expires
.
split
(
'mi'
)[
0
])
}
else
if
(
expires
.
endsWith
(
's'
))
{
exp
=
getSeconds
(
expires
.
split
(
's'
)[
0
])
}
else
exp
=
getYears
(
10
)
return
exp
}
function
getMonths
(
d
)
{
return
(
d
*
30
)
+
'd'
}
function
getYears
(
m
)
{
return
(
m
*
30
*
12
)
+
'd'
}
function
getMinutes
(
mi
)
{
return
(
mi
*
1000
*
60
)
+
'ms'
}
function
getSeconds
(
ms
)
{
return
(
ms
*
1000
)
+
'ms'
}
\ No newline at end of file
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