Browse Source

Moved credentials to external file so "real keys" can be used to test on production.

pull/4/head
jrtechs 6 years ago
parent
commit
ed756c0579
3 changed files with 13 additions and 11 deletions
  1. +2
    -2
      README.md
  2. +8
    -8
      server.js
  3. +3
    -1
      utils/sql.js

+ 2
- 2
README.md View File

@ -46,7 +46,7 @@ grant all on blog_name.* to blog_user@localhost identified by "password";
## Node Dependencies ## Node Dependencies
```bash ```bash
npm install express npm install express
npm install express-sessions
npm install express-session
npm install mysql npm install mysql
npm install sanitizer npm install sanitizer
npm install promise npm install promise
@ -54,5 +54,5 @@ npm install markdown
npm install markdown-to-html -g npm install markdown-to-html -g
npm install highlight npm install highlight
npm install crypto npm install crypto
npm i express-force-ssl
npm install express-force-ssl
``` ```

+ 8
- 8
server.js View File

@ -7,8 +7,6 @@
const http = require('http'); const http = require('http');
var https = require('https');
const url = require('url'); const url = require('url');
var express = require("express"); var express = require("express");
@ -16,12 +14,15 @@ var express = require("express");
var session = require('express-session'); var session = require('express-session');
const includes = require('./includes/includes.js'); const includes = require('./includes/includes.js');
var forceSsl = require('express-force-ssl');
//
const utils = require('./utils/utils.js');
//
// var forceSsl = require('express-force-ssl');
var app = express(); var app = express();
var fs = require('fs');
// var https = require('https');
//var key = fs.readFileSync('private.key'); //var key = fs.readFileSync('private.key');
//var cert = fs.readFileSync( 'primary.crt' ); //var cert = fs.readFileSync( 'primary.crt' );
@ -33,8 +34,7 @@ var fs = require('fs');
// ca: ca // ca: ca
// }; // };
//the secret is different on production
app.use(session({ secret: 'keyboard cat', cookie: { maxAge: 6000000 }}));
app.use(session({ secret: utils.getFileContents('../../session_secret'), cookie: { maxAge: 6000000 }}));
app.use(function(request, res) app.use(function(request, res)
{ {
@ -83,6 +83,6 @@ app.use(function(request, res)
//https.createServer(options, app).listen(443); //https.createServer(options, app).listen(443);
http.createServer(app).listen(80);
http.createServer(app).listen(8080);
//app.use(forceSsl); //app.use(forceSsl);

+ 3
- 1
utils/sql.js View File

@ -8,10 +8,12 @@ const crypto = require('crypto');
const qs = require('querystring'); const qs = require('querystring');
const utils = require('../utils/utils.js');
const con = mysql.createConnection({ const con = mysql.createConnection({
host: "localhost", host: "localhost",
user: "blog_user", user: "blog_user",
password: "password", //definitely not the password on production
password: utils.getFileContents('../../sql_secret'),
database: "blog_name" database: "blog_name"
}); });

Loading…
Cancel
Save