From 98b822f168aea4d1973c6834e7df66312e402845 Mon Sep 17 00:00:00 2001 From: Martin Donnelly Date: Thu, 12 May 2016 15:30:22 +0100 Subject: [PATCH] authentication --- logger-server.js | 6 +++--- server/loggerhandler.js | 10 +++++++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/logger-server.js b/logger-server.js index 516153a..22dd3b5 100644 --- a/logger-server.js +++ b/logger-server.js @@ -9,16 +9,16 @@ var express = require('express'), path = require('path'), http = require('http') ; -var authentication =require('basic-authentication'); + var app = express(); -app.use(authentication(({ +/*app.use(authentication(({ hash: 'sha256', // type of hash file: 'htpasswd.txt', // path of file suppress: true // suppress throwing Error if wrong user -}))); +})));*/ diff --git a/server/loggerhandler.js b/server/loggerhandler.js index 99cb102..6b12597 100644 --- a/server/loggerhandler.js +++ b/server/loggerhandler.js @@ -13,6 +13,14 @@ var router = express.Router(); var EventEmitter = require('events'); +var authentication =require('basic-authentication')(); + +var authOptions = { + hash: 'sha256', // type of hash + file: 'htpasswd.txt', // path of file + suppress: true // suppress throwing Error if wrong user +}; + var nano = require('nano')('http://martind2000:1V3D4m526i@localhost:5984'); var busEmitter = new EventEmitter(); @@ -44,7 +52,7 @@ var doInsertLog = (obj) =>{ busEmitter.on('saveLog', doInsertLog); -router.get('/', function (req, res) { +router.get('/', authentication(authOptions), function (req, res) { logger.debug('list..'); dbCouch.view('body','body',function(err, body) {