diff --git a/.gitignore b/.gitignore index b146c66..9f63e5a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ hardware/__Previews *.log software/config.js +software/node_modules diff --git a/software/auth/cardAuth.js b/software/auth/cardAuth.js index 7aa236d..e6e7e19 100644 --- a/software/auth/cardAuth.js +++ b/software/auth/cardAuth.js @@ -1,3 +1,32 @@ +var config = require("../config") +var request = require("request") + module.exports = function(fingerPrint, callback){ - callback(null, null); + request.post({ + url: config.accounts9 + "/interface/getUserByIdentity", + json: { + interfaceSecret: config.interfaceSecret, + identity: fingerPrint + }, + strictSSL: true, + }, function(error, response, body){ + if(error){ + return callback(error); + } + if(body.error === 'no-such-user'){ + return callback(null, null); + }else if(body.error){ + return callback(body.error, null); + }else{ + if(body.user.groups.some(function(g){ + return config.acceptGroup.some(function(h){ + return h === g; + }); + })){ + return callback(null, body.user.name); + }else{ + return callback(null, null); + } + } + }); } \ No newline at end of file diff --git a/software/config.example.js b/software/config.example.js index 212f466..b580027 100644 --- a/software/config.example.js +++ b/software/config.example.js @@ -4,6 +4,7 @@ logFile : "./access.log", sockFile : "/tmp/card9.sock", accounts9 : "https://accounts.net9.org", - setUid : "nobody", + setUid : "", //should not be root; should have access to the source code interfaceSecret : "Example", + acceptGroup: ["access-door"], }; \ No newline at end of file diff --git a/software/package.json b/software/package.json index b3d6222..fe5b821 100644 --- a/software/package.json +++ b/software/package.json @@ -6,5 +6,6 @@ "start": "sudo node ./card9.js" }, "dependencies": { + "request": "^2.53.0" } } diff --git a/software/test.packet b/software/test.packet index bbd11a5..ebf5906 100644 --- a/software/test.packet +++ b/software/test.packet Binary files differ