encrypt cookies

This commit is contained in:
b1ek 2023-02-19 01:29:43 +10:00
parent 8947ccc6eb
commit f6176f74cc
Signed by: blek
GPG Key ID: 14546221E3595D0C
3 changed files with 15 additions and 3 deletions

View File

@ -1,4 +1,4 @@
APP_PORT=8000
APP_DEBUG=true
# a 256-bit base64 encryption key
# a 32-bit base64 encryption key
APP_KEY=TKe8lE2IdkgGBUrB4nxdq7mGMf8PK29xqOnGa3vU0PBmNXADJrVA5LKd8pg6g/YO5aFG/ESzUleo/9Hve3SAe4rvwLBejD/SKOmDR4gbaMv4PuiNi8S2sYL30aVyi1OeaSTyYsfjteumkFxFVwrsxhDCX94xvNEuTEfS4repfLo=

View File

@ -4,11 +4,21 @@ require('./startup');
const express = require('express');
const app = express();
const session = require('express-session');
const cookie_parse = require('cookie-parser');
const cookie_encrypt = require('cookie-encrypter');
const { APP_PORT } = process.env;
const { APP_PORT, APP_KEY } = process.env;
app.use(require('./routes'));
app.use(express.static('public'))
app.use(express.static('public'));
app.use(cookie_parse(APP_KEY))
app.use(cookie_encrypt(APP_KEY));
app.use(session({
secret: APP_KEY,
cookie: { secure: true }
}));
const server = app.listen(APP_PORT, () => {
console.log("Listening on port " + APP_PORT);

View File

@ -12,6 +12,8 @@
"author": "",
"license": "ISC",
"dependencies": {
"cookie-encrypter": "^1.0.1",
"cookie-parser": "^1.4.6",
"crc-32": "^1.2.2",
"dotenv": "^16.0.3",
"express": "^4.18.2",