Commit 072988772d158b90c7edb88638f89cb8997c746a
1 parent
c726d602
Session: secret généré auto
Showing
3 changed files
with
11 additions
and
6 deletions
Show diff stats
Makefile
1 | +all: config/ci_com_pub.pem config/session_secret | |
2 | + | |
1 | 3 | config/ci_com_pub.pem: config/ci_com.pem |
2 | 4 | openssl rsa -pubout -in $< -out $@ |
3 | 5 | chmod 777 $@ |
... | ... | @@ -5,3 +7,6 @@ config/ci_com_pub.pem: config/ci_com.pem |
5 | 7 | config/ci_com.pem: |
6 | 8 | openssl genrsa -out $@ 1024 |
7 | 9 | chmod 700 $@ |
10 | + | |
11 | +config/session_secret: | |
12 | + cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1 > $@ | ... | ... |
app/routes/ApiRtes.js
... | ... | @@ -3,8 +3,10 @@ var PolyUserServ = require('../services/PolyUserServ'); |
3 | 3 | var DecryptServ = require('../services/DecryptServ'); |
4 | 4 | var ConvsServ = require('../services/ConvsServ'); |
5 | 5 | var MessServ = require('../services/MessServ'); |
6 | +var fs = require('fs'); | |
6 | 7 | var express = require('express'); |
7 | -session = require('express-session'); | |
8 | +var session = require('express-session'); | |
9 | +var MongoStore = require('connect-mongo')(session); | |
8 | 10 | |
9 | 11 | var api = express(); |
10 | 12 | |
... | ... | @@ -98,7 +100,9 @@ api.use(session({ |
98 | 100 | name: 'membreCool', |
99 | 101 | resave: false, |
100 | 102 | saveUninitialized: true, |
101 | - secret: "Le Club Info c'est cool" // TODO Vrai secret https://gist.github.com/earthgecko/3089509 | |
103 | + secret: fs.readFileSync('config/session_secret', { | |
104 | + encoding: 'UTF8' | |
105 | + }) | |
102 | 106 | })); |
103 | 107 | |
104 | 108 | api.get('/session', function (req, res) { // Informations sur la session | ... | ... |
server.js
... | ... | @@ -2,7 +2,6 @@ |
2 | 2 | var express = require('express'); |
3 | 3 | var mongoose = require('mongoose'); |
4 | 4 | var bodyParser = require('body-parser'); |
5 | -var cookieParser = require('cookie-parser'); | |
6 | 5 | |
7 | 6 | // Application ================================================================ |
8 | 7 | |
... | ... | @@ -20,9 +19,6 @@ app.use(bodyParser.urlencoded({ |
20 | 19 | extended: true |
21 | 20 | })); |
22 | 21 | |
23 | -// Cookie-parser | |
24 | -app.use(cookieParser()); | |
25 | - | |
26 | 22 | // Routes |
27 | 23 | require('./app/routes')(app); |
28 | 24 | ... | ... |