diff --git a/controllers/authentication.js b/controllers/authentication.js new file mode 100644 index 0000000..8f31df6 --- /dev/null +++ b/controllers/authentication.js @@ -0,0 +1,126 @@ +/*========================== + * Subscriptions + * + * @description: Managing the client subscription to be notified about a given topic + * @author: Government of Canada; @duboisp + * @version: 1.0 + ===========================*/ + + const axios = require('axios'); + + const NotifyClient = require('notifications-node-client').NotifyClient; // https://docs.notifications.service.gov.uk/node.html#node-js-client-documentation + + const entities = require("entities"); + + const dbConn = module.parent.exports.dbConn; + const ObjectId = require('mongodb').ObjectId; + + var options = { + apiVersion: 'v1', // default + endpoint: 'http://127.0.0.1:8200' // default + //token: '1234' // optional client token; can be fetched after valid initialization of the server + }; + + // get new instance of the client + //const vault = require("node-vault"); + + const processEnv = process.env, + _devLog = !!!processEnv.prodNoLog, + _keySalt = processEnv.keySalt || "salt", + _validHosts = JSON.parse(processEnv.validHosts || '["localhost:8080"]'), + _errorPage = processEnv.errorPage || "https://canada.ca", + _successJSO = processEnv.successJSO || { statusCode: 200, ok: 1 }, + _cErrorsJSO = processEnv.cErrorsJSO || { statusCode: 400, bad: 1, msg: "Bad request" }, + _sErrorsJSO = processEnv.sErrorsJSO || { statusCode: 500, err: 1 }, + _notifyEndPoint = processEnv.notifyEndPoint || "https://api.notification.alpha.canada.ca", + _confirmBaseURL = processEnv.confirmBaseURL || "https://apps.canada.ca/x-notify/subs/confirm/", + _nbMinutesBF = processEnv.notSendBefore || 25, // Default of 25 minutes. + _bypassSubscode = processEnv.subscode, + _topicCacheLimit = processEnv.topicCacheLimit || 50, + _notifyCacheLimit = processEnv.notifyCacheLimit || 40, + _flushAccessCode = processEnv.flushAccessCode, + _flushAccessCode2 = processEnv.flushAccessCode2, + _notifyUsTimeLimit = processEnv.notifyUsTimeLimit || 180000, + _subsLinkSuffix = processEnv.subsLinkSuffix || "853e0212b92a127"; + + let notifyCached = [], + notifyCachedIndexes = [], + topicCached = [], + topicCachedIndexes = [], + fakeSubsIncrement = 0, + _notifyUsNotBeforeTimeLimit = 0; + + + + /* + // init vault server + vault.init({ secret_shares: 1, secret_threshold: 1 }) + .then( (result) => { + var keys = result.keys; + // set token for all following requests + vault.token = result.root_token; + // unseal vault server + console.log("result.root_token : " + result.root_token); + return vault.unseal({ secret_shares: 1, key: keys[0] }) + }) + .catch(console.error); + + + vault.write('secret/hello', { value: 'world', lease: '1s' }) + .then( () => vault.read('secret/hello')) + .then( () => vault.delete('secret/hello')) + .catch(console.error); + */ + + // + // Get key + // + // @return; a JSON containing valid key + // + exports.getKey = ( req, res, next ) => { + + generateAuthenticationKey().then(data => { + res.json({data}) + }) + }; + + + + // + // Get Authentication Token key from Vault + // + // @return; a JSON containing valid key + // + generateAuthenticationKey = () => { + + + + /*return axios.get("http://127.0.0.1:8200/v1/secret?help=1", + { headers: {'X-Vault-Token': 'root'}} + ) + .then((response) => { + console.log(response.data); + //console.log(response.status); + return response.data + }, (error) => { + console.log(error); + }); +*/ + /// http://localhost:8200/v1/sys/seal-status + // https://dog.ceo/api/breeds/list/all + // http://172.18.0.1:8200/v1/sys/seal-status + return axios.get("http://ec2-100-26-121-207.compute-1.amazonaws.com:8200/v1/sys/seal-status", + { headers: {'Content-Type': 'application/json'}} + ) + .then((response) => { + console.log(response.data); + //console.log(response.status); + return response.data + }, (error) => { + console.log(error); + }); + + + } + + diff --git a/controllers/users.js b/controllers/users.js new file mode 100644 index 0000000..0c956db --- /dev/null +++ b/controllers/users.js @@ -0,0 +1,236 @@ +/** + * Module dependencies. + */ +const express = require('express'); // HTTP server +const bcrypt = require('bcryptjs'); +const jwt = require('jsonwebtoken'); +const cors = require('cors'); // CORS +const crypto = require('crypto'); + +const userNameSecretKeyCollection = module.parent.exports.userNameSecretKeyCollection; + +const userNamePasswordCollection = module.parent.exports.userNamePasswordCollection; + +userNameSecretKeyCollection.createIndex( { "userName": 1 }, { unique: true } ); + +/** + * Create Express server. + */ +const usersRouter = express(); + + +// Generate the secret key +let keyMap = new Map() +const NO_USER = "noUser"; +var username; + +usersRouter.get('/getSecretKey', (req, res) => { + const secretKey = crypto.randomBytes(64).toString('base64').replace(/\//g,'_').replace(/\+/g,'-'); + console.log(secretKey); + // first loading to get secret key, there is no way to get to know the user info + keyMap.set(NO_USER, secretKey); + + + userNameSecretKeyCollection.replaceOne( + { userName: NO_USER }, + { userName: NO_USER, secretKey: secretKey }, + { upsert : true} + ).then( () => { + console.log("1 document inserted on api /test/getSecretKey "); + }).catch( ( e ) => { + console.log( "err while generate secretKey on api /test/getSecretKey" ); + console.log( e ); + }); + + res.json({ secretKey: secretKey }) + }) + + + +// Get all the username Password +usersRouter.get('/getAllUserNamePassword', (req, res) => { + + userNamePasswordCollection.find({}).toArray(function(err, result) { + if (err) throw err; + console.log(result); + res.sendStatus(200); + }); + } + ); + + +// Register +usersRouter.post('/register', (req, res) => { + var { username, password } = req.body; + console.log(username + " as username and password " + password); + let errors = []; + + userNamePasswordCollection.findOne({ username: username }).then(user => { + if (user) { + errors.push({ msg: 'UserName already exists' }); + console.log("UserName already exists"); + res.status(200).send("UserName already exists"); + } else { + bcrypt.genSalt(10, (err, salt) => { + bcrypt.hash(password, salt, (err, hash) => { + if (err) throw err; + password = hash; + userNamePasswordCollection.insertOne({username: username, password: password}) + .then(user => { + console.log("You are now registered and can log in"); + //res.redirect('/users/login'); + res.sendStatus(200); + }) + .catch(err => { + console.log(err); + res.sendStatus(500); + }); + }); + }); + } + }); + } + ); + + +// Generate the key and persist in hashmap +usersRouter.post('/login', verifyToken, (req, res) => { + // Authenticate User + //res.status(500).send('The email is not registered'); + //console.log( req.headers ); + //console.log( req.body ); + + username = req.body.username; + const password = req.body.password; + console.log("username is " + username + " and password is " + password); + var secretKey; + + // Match user + userNamePasswordCollection.findOne({ + username: username + }).then(user => { + if (!user) { + console.log("That email is not registered"); + res.status(500).send('The email is not registered'); + } else { + // Match password + bcrypt.compare(password, user.password, (err, isMatch) => { + if (err) throw err; + if (isMatch) { + console.log("Password is matched and user can login"); + secretKey = crypto.randomBytes(64).toString('base64').replace(/\//g,'_').replace(/\+/g,'-'); + console.log(secretKey); + keyMap.set(username, secretKey); + + userNameSecretKeyCollection.replaceOne( + { userName: username }, + { userName: username, secretKey: secretKey }, + { upsert: true } + ).then( () => { + console.log("1 document inserted on api /test/login"); + res.json({ secretKey: secretKey }); + }).catch( ( e ) => { + console.log( "err while generate secretKey on api /test/login" ); + console.log( e ); + }); + } else { + console.log("Password incorrect"); + } + }); + } + }); + + + }) + + +// List mailing for the user +usersRouter.get( '/mailing/create/:topicId', cors( { "origin": "*" } ), + verifyToken, ( req, res ) => { + const user = req.user; + res.json( { + id: "uid-33", + created: "2020-06-16", + updated: "2020-06-16", + title: "Mailing Title", + user + } ); + +}); + +// Logout +usersRouter.get('/logout', (req, res) => { + req.logout(); + // delete the user related document in the collection + console.log("logout username : " + username) + var myquery = { username: username }; + userNameSecretKeyCollection.deleteOne(myquery, function(err, obj) { + if (err) throw err; + console.log("1 document deleted" + obj); + }); + + res.sendStatus(200); + + }); + +// Authenticate the JWT and verify that if it is tampered or not +// FORMATE OF TOKEN +// Authorization : Bearer +// Verify Token +function verifyToken(req, res, next) { + // check if the secretKey is generated by server + // check if the request include jws in http header authroization + const authHeader = req.headers['authorization'] + const token = authHeader && authHeader.split(' ')[1] + if (token == null) return res.sendStatus(401) + console.log("incoming token payload : " + token); + + let secretKey =''; + if (req.body.secretKey){ + secretKey = req.body.secretKey; + jwt.verify(token, secretKey, (err, decoded) => { + console.log(err) + if (err) return res.sendStatus(403) + console.log("decoded payload : " + decoded.name); + console.log("decoded payload : " + decoded.sub); + console.log("decoded payload : " + decoded.iat); + req.user = decoded + next() + }) + } else { + let payload = token.split('.')[1]; + let buff = new Buffer(payload, 'base64'); + let payLoadJson = JSON.parse(buff.toString('ascii')); + let userNameFromPayload = payLoadJson.name; + secretKey = keyMap.get(userNameFromPayload); + + + userNameSecretKeyCollection.find({}).toArray(function(err, result) { + if (err) throw err; + console.log(result); + }); + + userNameSecretKeyCollection.findOne( + { userName: userNameFromPayload } + ).then((documentRecord) => { + console.log("userName in payload in verify : " + documentRecord.userName); + console.log("secretKey in mongoDb : " + documentRecord.secretKey); + jwt.verify(token, documentRecord.secretKey, (err, decoded) => { + console.log(err) + if (err) return res.sendStatus(403) + console.log("decoded payload : " + decoded.name); + console.log("decoded payload : " + decoded.sub); + console.log("decoded payload : " + decoded.iat); + req.user = decoded + next() + }) + }).catch( (e) => { + console.log( "look up document by useName in verify" ); + console.log( e ); + }); + } + + } + +module.exports = usersRouter; + diff --git a/controllers/usersBackup.js b/controllers/usersBackup.js new file mode 100644 index 0000000..397271a --- /dev/null +++ b/controllers/usersBackup.js @@ -0,0 +1,148 @@ +/** + * Module dependencies. + */ +const express = require('express'); // HTTP server +const bcrypt = require('bcryptjs'); +const jwt = require('jsonwebtoken'); +const crypto = require('crypto'); + +const userNameSecretKeyCollection = module.parent.exports.userNameSecretKeyCollection; + +const userNamePasswordCollection = module.parent.exports.userNamePasswordCollection; + +userNameSecretKeyCollection.createIndex( { "userName": 1 }, { unique: true } ); + +let keyMap = new Map() +const NO_USER = "noUser"; + + +exports.getSecretKey = ( req, res, next ) => { + + const secretKey = crypto.randomBytes(64).toString('base64').replace(/\//g,'_').replace(/\+/g,'-'); + console.log(secretKey); + // first loading to get secret key, there is no way to get to know the user info + keyMap.set(NO_USER, secretKey); + + + userNameSecretKeyCollection.replaceOne( + { userName: NO_USER }, + { userName: NO_USER, secretKey: secretKey }, + { upsert : true} + ).then( () => { + console.log("1 document inserted on api /test/getSecretKey "); + }).catch( ( e ) => { + console.log( "err while generate secretKey on api /test/getSecretKey" ); + console.log( e ); + }); + + res.json({ secretKey: secretKey }) +}; + + +// Get all the username Password +exports.getAllUserNamePassword = ( req, res, next ) => { + + userNamePasswordCollection.find({}).toArray(function(err, result) { + if (err) throw err; + console.log(result); + res.sendStatus(200); + }); +}; + +// Register +exports.register = ( req, res, next ) => { + + + var { username, password } = req.body; + console.log(username + " as username and password " + password); + let errors = []; + + userNamePasswordCollection.findOne({ username: username }).then(user => { + if (user) { + errors.push({ msg: 'UserName already exists' }); + console.log("UserName already exists"); + res.status(200).send("UserName already exists"); + } else { + bcrypt.genSalt(10, (err, salt) => { + bcrypt.hash(password, salt, (err, hash) => { + if (err) throw err; + password = hash; + userNamePasswordCollection.insertOne({username: username, password: password}) + .then(user => { + console.log("You are now registered and can log in"); + //res.redirect('/users/login'); + res.sendStatus(200); + }) + .catch(err => { + console.log(err); + res.sendStatus(500); + }); + }); + }); + } + }); +}; + +// Generate the key and persist in hashmap +exports.login = ( req, res, next ) => { + + + // Authenticate User + //res.status(500).send('The email is not registered'); + //console.log( req.headers ); + //console.log( req.body ); + + const username = req.body.username; + const password = req.body.password; + console.log("username is " + username + " and password is " + password); + var secretKey; + + // Match user + userNamePasswordCollection.findOne({ + username: username + }).then(user => { + if (!user) { + console.log("That email is not registered"); + res.status(500).send('The email is not registered'); + } else { + // Match password + bcrypt.compare(password, user.password, (err, isMatch) => { + if (err) throw err; + if (isMatch) { + console.log("Password is matched and user can login"); + secretKey = crypto.randomBytes(64).toString('base64').replace(/\//g,'_').replace(/\+/g,'-'); + console.log(secretKey); + keyMap.set(username, secretKey); + + userNameSecretKeyCollection.replaceOne( + { userName: username }, + { userName: username, secretKey: secretKey }, + { upsert: true } + ).then( () => { + console.log("1 document inserted on api /test/login"); + res.json({ secretKey: secretKey }); + }).catch( ( e ) => { + console.log( "err while generate secretKey on api /test/login" ); + console.log( e ); + }); + } else { + console.log("Password incorrect"); + } + }); + } + }); +}; + +// List mailing for the user +exports.getMailingByTopicId = ( req, res, next ) => { + + const user = req.user; + res.json( { + id: "uid-33", + created: "2020-06-16", + updated: "2020-06-16", + title: "Mailing Title", + user + } ); +}; + diff --git a/docker-compose.yml b/docker-compose.yml index 1bca26d..dd173d0 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -28,4 +28,4 @@ services: - x-notify-net networks: x-notify-net: - driver: bridge + diff --git a/package.json b/package.json index 689a021..71cd12a 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ }, "dependencies": { "aws-sdk": "^2.659.0", + "bcryptjs": "^2.4.3", "chalk": "^3.0.0", "compression": "^1.7.4", "cors": "^2.8.5", @@ -26,9 +27,12 @@ "errorhandler": "^1.5.1", "express": "^4.17.1", "express-status-monitor": "^1.2.8", + "jsonwebtoken": "^8.5.1", "mongodb": "^3.5.5", "morgan": "^1.9.1", "mustache": "^4.0.1", + "node-vault": "^0.9.18", + "node-vault-client": "^0.5.6", "nodemailer": "^6.4.6", "notifications-node-client": "^4.7.2", "passport": "^0.4.1", diff --git a/requests.rest b/requests.rest new file mode 100644 index 0000000..dd35178 --- /dev/null +++ b/requests.rest @@ -0,0 +1,41 @@ +GET http://localhost:8080/api/v0.1/subs/getAuthenticationKey + +### +GET https://dog.ceo/api/breeds/list/all + +### + +#GET http://127.0.0.1:8200/v1/auth/token/lookup-self +GET http://127.0.0.1:8200/v1/secret?help=1 +Content-Type: application/json + +{ + "X-Vault-Token": "root" +} + +### + +DELETE http://localhost:8080/logout +Content-Type: application/json + +{ + "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiSmltIiwiaWF0IjoxNTY4NzU5OTIyfQ.RT6wszuCeFLwC_6ksmNMIELxiC5s-uRivfRxyZof5ag" +} + +### + +POST http://localhost:8080/token +Content-Type: application/json + +{ + "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuYW1lIjoiSmltIiwiaWF0IjoxNTY4NzU5OTIyfQ.RT6wszuCeFLwC_6ksmNMIELxiC5s-uRivfRxyZof5ag" +} + +### + +POST http://localhost:8080/login +Content-Type: application/json + +{ + "username": "Jim" +} \ No newline at end of file diff --git a/server.js b/server.js index 5cd6359..ca8b03a 100644 --- a/server.js +++ b/server.js @@ -19,7 +19,6 @@ const passport = require('passport'); // Authentication const BasicStrategy = require('passport-http').BasicStrategy; const bodyParser = require('body-parser'); -//const crypto = require('crypto'); // To encrypt Notify keys const MongoClient = require('mongodb').MongoClient; @@ -53,15 +52,17 @@ passport.use(new BasicStrategy({ qop: 'auth' }, const app = express(); - /** * Connect to MongoDB. */ MongoClient.connect( processEnv.MONGODB_URI || '', {useUnifiedTopology: true} ).then( ( mongoInstance ) => { + var dbConnInstance = mongoInstance.db( processEnv.MONGODB_NAME || 'subs' );; - module.exports.dbConn = mongoInstance.db( processEnv.MONGODB_NAME || 'subs' ); - //app.emit('ready'); + module.exports.dbConn = dbConnInstance; + module.exports.userNameSecretKeyCollection = dbConnInstance.collection("userNameSecretKey"); + module.exports.userNamePasswordCollection = dbConnInstance.collection("userNamePassword"); + /** @@ -71,6 +72,10 @@ MongoClient.connect( processEnv.MONGODB_URI || '', {useUnifiedTopology: true} ). const managersController = require('./controllers/managers'); const smtpController = require('./controllers/sendsmtp'); + const authenticationController = require('./controllers/authentication'); + + //const usersController = require('./controllers/users'); + /** @@ -82,16 +87,19 @@ MongoClient.connect( processEnv.MONGODB_URI || '', {useUnifiedTopology: true} ). app.use(expressStatusMonitor( { path: processEnv.ServerStatusPath || "/admin/sys-status" } )); app.use(compression()); app.use(logger( processEnv.LOG_FORMAT || 'dev')); - app.use(bodyParser.json()); // for parsing application/json - app.disable('x-powered-by'); + + /** + * Middleware to enable cors + */ + app.use( cors( { "origin": "*" } ) ); /** * Subscriber routes. */ - app.get('/api/v0.1/subs/postkey', subsController.getKey); + app.get('/api/v0.1/subs/getAuthenticationKey', authenticationController.getKey); app.post('/api/v0.1/subs/email/add', // Need to do more testing // passport.authenticate('basic', { session: false }), @@ -162,6 +170,20 @@ MongoClient.connect( processEnv.MONGODB_URI || '', {useUnifiedTopology: true} ). bodyParser.urlencoded({extended:false, limit: '10kb'}), smtpController.sendMailPOST); + /** + * Users related handlers such as register, login and verification + */ + + app.use('/api/v0.1/users', require('./controllers/users')); + + /*app.get('/api/v0.1/users/getSecretKey', usersController.getSecretKey); + app.get('/api/v0.1/users/getAllUserNamePassword', usersController.getAllUserNamePassword); + app.post('/api/v0.1/users/register', usersController.register); + app.post('/api/v0.1/users/login', verifyToken, usersController.login); + app.get('/api/v0.1/users/mailing/create/:topicId', cors( { "origin": "*" } ), verifyToken, usersController.getMailingByTopicId); + */ + + /** * Error Handler. */ diff --git a/startupNotify.txt b/startupNotify.txt new file mode 100644 index 0000000..bacf41e --- /dev/null +++ b/startupNotify.txt @@ -0,0 +1,92 @@ +Step 1/9 : FROM node:12-slim + ---> 396c358d2c97 +Step 2/9 : ARG NODE_ENV=development + ---> Using cache + ---> ec22cd84ed28 +Step 3/9 : ENV NODE_ENV=${NODE_ENV} + ---> Using cache + ---> a0271bcb4eb4 +Step 4/9 : WORKDIR ./ + ---> Using cache + ---> 55ddc83e254b +Step 5/9 : COPY package*.json ./ + ---> Using cache + ---> 6a097baab7ca +Step 6/9 : RUN npm install -g nodemon + ---> Using cache + ---> 39f66d28de92 +Step 7/9 : RUN npm install + ---> Using cache + ---> 694037fbd2fb +Step 8/9 : COPY . . + ---> ebfd24661b02 +Step 9/9 : CMD [ "npm", "start" ] + ---> Running in 5fce3a565b5c +Removing intermediate container 5fce3a565b5c + ---> 5b3d136b188a + +Successfully built 5b3d136b188a +Successfully tagged x-notify_x-notify:latest +Attaching to 7d6425291c36_myvault, x-notify-mongo, x-notify +x-notify-mongo | 2020-06-18T20:37:41.677+0000 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none' +x-notify-mongo | 2020-06-18T20:37:41.679+0000 W ASIO [main] No TransportLayer configured during NetworkInterface startup +x-notify-mongo | 2020-06-18T20:37:41.680+0000 I CONTROL [initandlisten] MongoDB starting : pid=1 port=27017 dbpath=/data/db 64-bit host=049c2b5cf7e7 +x-notify-mongo | 2020-06-18T20:37:41.680+0000 I CONTROL [initandlisten] db version v4.2.6 +x-notify-mongo | 2020-06-18T20:37:41.680+0000 I CONTROL [initandlisten] git version: 20364840b8f1af16917e4c23c1b5f5efd8b352f8 +x-notify-mongo | 2020-06-18T20:37:41.680+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.1.1 11 Sep 2018 +x-notify-mongo | 2020-06-18T20:37:41.680+0000 I CONTROL [initandlisten] allocator: tcmalloc +x-notify-mongo | 2020-06-18T20:37:41.680+0000 I CONTROL [initandlisten] modules: none +x-notify-mongo | 2020-06-18T20:37:41.680+0000 I CONTROL [initandlisten] build environment: +x-notify-mongo | 2020-06-18T20:37:41.680+0000 I CONTROL [initandlisten] distmod: ubuntu1804 +x-notify-mongo | 2020-06-18T20:37:41.680+0000 I CONTROL [initandlisten] distarch: x86_64 +x-notify-mongo | 2020-06-18T20:37:41.680+0000 I CONTROL [initandlisten] target_arch: x86_64 +x-notify-mongo | 2020-06-18T20:37:41.680+0000 I CONTROL [initandlisten] options: { net: { bindIp: "*" } } +7d6425291c36_myvault | error loading configuration from /vault/config/vault.json: stat /vault/config/vault.json: no such file or directory +x-notify-mongo | 2020-06-18T20:37:41.680+0000 W STORAGE [initandlisten] Detected unclean shutdown - /data/db/mongod.lock is not empty. +x-notify-mongo | 2020-06-18T20:37:41.680+0000 I STORAGE [initandlisten] Detected data files in /data/db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'. +x-notify-mongo | 2020-06-18T20:37:41.680+0000 W STORAGE [initandlisten] Recovering data from the last clean checkpoint. +x-notify-mongo | 2020-06-18T20:37:41.680+0000 I STORAGE [initandlisten] +x-notify-mongo | 2020-06-18T20:37:41.680+0000 I STORAGE [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine +x-notify-mongo | 2020-06-18T20:37:41.680+0000 I STORAGE [initandlisten] ** See http://dochub.mongodb.org/core/prodnotes-filesystem +x-notify-mongo | 2020-06-18T20:37:41.680+0000 I STORAGE [initandlisten] wiredtiger_open config: create,cache_size=483M,cache_overflow=(file_max=0M),session_max=33000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000,close_scan_interval=10,close_handle_minimum=250),statistics_log=(wait=0),verbose=[recovery_progress,checkpoint_progress], +7d6425291c36_myvault exited with code 1 +x-notify-mongo | 2020-06-18T20:37:42.184+0000 I STORAGE [initandlisten] WiredTiger message [1592512662:184002][1:0x7ff742105b00], txn-recover: Recovering log 53 through 54 +x-notify-mongo | 2020-06-18T20:37:42.225+0000 I STORAGE [initandlisten] WiredTiger message [1592512662:225435][1:0x7ff742105b00], txn-recover: Recovering log 54 through 54 +x-notify-mongo | 2020-06-18T20:37:42.298+0000 I STORAGE [initandlisten] WiredTiger message [1592512662:298325][1:0x7ff742105b00], txn-recover: Main recovery loop: starting at 53/3200 to 54/256 +x-notify-mongo | 2020-06-18T20:37:42.298+0000 I STORAGE [initandlisten] WiredTiger message [1592512662:298852][1:0x7ff742105b00], txn-recover: Recovering log 53 through 54 +x-notify-mongo | 2020-06-18T20:37:42.357+0000 I STORAGE [initandlisten] WiredTiger message [1592512662:357637][1:0x7ff742105b00], file:sizeStorer.wt, txn-recover: Recovering log 54 through 54 +x-notify-mongo | 2020-06-18T20:37:42.397+0000 I STORAGE [initandlisten] WiredTiger message [1592512662:397326][1:0x7ff742105b00], file:sizeStorer.wt, txn-recover: Set global recovery timestamp: (0, 0) +x-notify | +x-notify | > x-notify@1.0.0 start / +x-notify | > nodemon -L server.js +x-notify | +x-notify-mongo | 2020-06-18T20:37:42.476+0000 I RECOVERY [initandlisten] WiredTiger recoveryTimestamp. Ts: Timestamp(0, 0) +x-notify-mongo | 2020-06-18T20:37:42.482+0000 I STORAGE [initandlisten] Timestamp monitor starting +x-notify-mongo | 2020-06-18T20:37:42.490+0000 I CONTROL [initandlisten] +x-notify-mongo | 2020-06-18T20:37:42.490+0000 I CONTROL [initandlisten] ** WARNING: Access control is not enabled for the database. +x-notify-mongo | 2020-06-18T20:37:42.490+0000 I CONTROL [initandlisten] ** Read and write access to data and configuration is unrestricted. +x-notify-mongo | 2020-06-18T20:37:42.490+0000 I CONTROL [initandlisten] +x-notify-mongo | 2020-06-18T20:37:42.498+0000 I SHARDING [initandlisten] Marking collection local.system.replset as collection version: +x-notify-mongo | 2020-06-18T20:37:42.500+0000 I STORAGE [initandlisten] Flow Control is enabled on this deployment. +x-notify-mongo | 2020-06-18T20:37:42.501+0000 I SHARDING [initandlisten] Marking collection admin.system.roles as collection version: +x-notify-mongo | 2020-06-18T20:37:42.501+0000 I SHARDING [initandlisten] Marking collection admin.system.version as collection version: +x-notify-mongo | 2020-06-18T20:37:42.504+0000 I SHARDING [initandlisten] Marking collection local.startup_log as collection version: +x-notify-mongo | 2020-06-18T20:37:42.507+0000 I FTDC [initandlisten] Initializing full-time diagnostic data capture with directory '/data/db/diagnostic.data' +x-notify-mongo | 2020-06-18T20:37:42.510+0000 I SHARDING [LogicalSessionCacheRefresh] Marking collection config.system.sessions as collection version: +x-notify-mongo | 2020-06-18T20:37:42.511+0000 I SHARDING [LogicalSessionCacheReap] Marking collection config.transactions as collection version: +x-notify-mongo | 2020-06-18T20:37:42.511+0000 I NETWORK [listener] Listening on /tmp/mongodb-27017.sock +x-notify-mongo | 2020-06-18T20:37:42.511+0000 I NETWORK [listener] Listening on 0.0.0.0 +x-notify-mongo | 2020-06-18T20:37:42.512+0000 I NETWORK [listener] waiting for connections on port 27017 +x-notify | [nodemon] 2.0.4 +x-notify | [nodemon] to restart at any time, enter `rs` +x-notify | [nodemon] watching path(s): *.* +x-notify | [nodemon] watching extensions: js,mjs,json +x-notify | [nodemon] starting `node server.js` +x-notify | event-loop-stats not found, ignoring event loop metrics... +x-notify-mongo | 2020-06-18T20:37:43.003+0000 I FTDC [ftdc] Unclean full-time diagnostic data capture shutdown detected, found interim file, some metrics may have been lost. OK +x-notify-mongo | 2020-06-18T20:37:43.010+0000 I SHARDING [ftdc] Marking collection local.oplog.rs as collection version: +x-notify-mongo | 2020-06-18T20:37:43.050+0000 I NETWORK [listener] connection accepted from 172.18.0.3:54218 #1 (1 connection now open) +x-notify-mongo | 2020-06-18T20:37:43.055+0000 I NETWORK [conn1] received client metadata from 172.18.0.3:54218 conn1: { driver: { name: "nodejs", version: "3.5.7" }, os: { type: "Linux", name: "linux", architecture: "x64", version: "4.19.76-linuxkit" }, platform: "'Node.js v12.16.3, LE (unified)" } +x-notify | ? App is running at http://localhost:8080 in development mode +x-notify | Press CTRL-C to stop +x-notify | diff --git a/vault/config/vault.json b/vault/config/vault.json new file mode 100644 index 0000000..38db4bc --- /dev/null +++ b/vault/config/vault.json @@ -0,0 +1,6 @@ +{ + "backend": {"file": {"path": "/vault/file"}}, + "listener": {"tcp": {"address": "0.0.0.0:8200", "tls_disable": 1}}, + "default_lease_ttl": "168h", + "max_lease_ttl": "0h" +} \ No newline at end of file