Commit 286ef1b5 by zCaesar

not auth

parent 8ac40526
...@@ -100,52 +100,64 @@ module.exports = function (options = {}) { ...@@ -100,52 +100,64 @@ module.exports = function (options = {}) {
} }
var cachekey = 'auth:' + req.body.client_id + ':' + req.body.username + ':' + req.body.password; var cachekey = 'auth:' + req.body.client_id + ':' + req.body.username + ':' + req.body.password;
var authstatus = cache.get(cachekey); var authstatus = cache.get(cachekey);
if (typeof (authstatus) == 'undefined') { // if (typeof (authstatus) == 'undefined') {
// cache missed // // cache missed
authCheck(req.body.client_id, req.body.username, req.body.password, function (result) { // authCheck(req.body.client_id, req.body.username, req.body.password, function (result) {
cache.set(cachekey, result); // cache.set(cachekey, result);
if (result) { // if (result) {
require('./redis/on_register').on_register_redis(req.body.client_id).then(status => { // require('./redis/on_register').on_register_redis(req.body.client_id).then(status => {
console.log('redis:status: ' + status) // console.log('redis:status: ' + status)
if (status) { // if (status) {
res.send({ // res.send({
"result": "ok" // "result": "ok"
}); // });
} else { // } else {
res.send({ // res.send({
"result": "no" // "result": "no"
}); // });
} // }
}) // })
} else { // } else {
res.send({ // res.send({
"result": "no" // "result": "no"
}); // });
} // }
// const util = require('util') // // const util = require('util')
// console.log(util.inspect(status, false, null, true)) // // console.log(util.inspect(status, false, null, true))
}); // });
} // }
else { // else {
if (authstatus) { // if (authstatus) {
require('./redis/on_register').on_register_redis(req.body.client_id).then(status => { // require('./redis/on_register').on_register_redis(req.body.client_id).then(status => {
console.log('redis:status: ' + status) // console.log('redis:status: ' + status)
if (status) { // if (status) {
res.send({ // res.send({
"result": "ok" // "result": "ok"
}); // });
} else { // } else {
res.send({ // res.send({
"result": "no" // "result": "no"
}); // });
} // }
}) // })
// } else {
// res.send({
// "result": "no"
// });
// }
// }
require('./redis/on_register').on_register_redis(req.body.client_id).then(status => {
console.log('redis:status: ' + status)
if (status) {
res.send({
"result": "ok"
});
} else { } else {
res.send({ res.send({
"result": "no" "result": { 'error': "not allowed" }
}); });
} }
} })
next(); next();
} }
else { else {
......
{ {
"authserv_host" : "203.151.51.4", "device_registry_host" : "alpha.nexpie.io",
"authserv_port" : 31081, "device_registry_port" : 8990,
"pubca": "-----BEGIN PUBLIC KEY-----\nMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA0oW2b1az7MLTRBQojy8e\nYTmVUcbrHBykyMZCkwt4OdL/4zD6jhOmE9JMr3NfRxEJ2BVj7gasEH2h/mpNRtSK\nHjKsgmFWt22QR/TNwNu7AHUiu+7pxyeOz6IDW9bzrptwwwvFz8wc0oKah6fs0cNY\n/Ln5QwY5CWpGJmHF5BOFE5R9PjC3bY2roKwDbKiw4Kx1rbRxwbSzvFGtBMVyK0Rv\nJpWEN6wTEesAI/bLkPth712zfY/PXFi9Vei/gcLxptceISj/o+PUZm4F6u+rHGGt\nOlcBI8lKiCBO8bggmGgpGCZ1fomj5pOPfInl/6Nn4X0gk/4s0MB7zuhBv45zxF8J\ntbzqQ9TVPdUewMtR5UWoPMGiGt6ZOYRAAmGYSWCsa7hD3plcg0NXYXVuLinyxmgd\nKUv0JmmDqWdkNme9W6m42Jb/zEACcneIIVgUeDkadYaJSjY05d2gn/Vn24f0hqp2\nSQ41fYBxw8eKUJLBNo2c9l+Vz7w/dln4cqI/hatXqOVvLml3CKBGwT9hFjufVTpr\nX5WgDzAxGAl0kO0IucInL/XROezsVcxhyJ2dp44KPOoSIUW8dFz7HNq4t9ENzcPV\nvYfvyS0l00p+ivaqT9iV53Ash6f+tHOR5arTNsuM3DHTi3Fi6qIhXSW5qGUl401c\nzSaVroFHIeQI0ZcTxzAOvS0CAwEAAQ==\n-----END PUBLIC KEY-----",
"device_registry_host" : "127.0.0.1", "token_registry_host" : "alpha.nexpie.io",
"device_registry_port" : 8080 "token_registry_port" : 8790,
"auth_on_register_debug" : true,
"auth_on_publish_debug" : true,
"auth_on_subscribe_debug" : true,
"on_publish_debug" : true,
"on_deliver_debug" : true,
"on_unsubscribe_debug" : true,
"on_offline_debug" : true
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment