option for insecure cookies in production mode, and add missing stuff to example config

merge-requests/208/head
fatchan 5 years ago
parent f31d4123f3
commit f7efa9f34f
  1. 3
      configs/main.json.example
  2. 3
      models/pages/captcha.js
  3. 2
      server.js

@ -10,6 +10,7 @@
"tripcodeSecret": "long random string", "tripcodeSecret": "long random string",
"ipHashSecret": "long random string", "ipHashSecret": "long random string",
"postPasswordSecret": "long random string", "postPasswordSecret": "long random string",
"secureCookies": true,
"cacheTemplates": true, "cacheTemplates": true,
"pruneModlogs": true, "pruneModlogs": true,
"enableUserBoards": true, "enableUserBoards": true,
@ -74,6 +75,8 @@
}, },
"boardDefaults": { "boardDefaults": {
"theme": "lain", "theme": "lain",
"codeTheme": "ir-black",
"sfw": false,
"locked": false, "locked": false,
"unlisted": false, "unlisted": false,
"captchaMode": 0, "captchaMode": 0,

@ -2,6 +2,7 @@
const { Captchas, Ratelimits } = require(__dirname+'/../../db/') const { Captchas, Ratelimits } = require(__dirname+'/../../db/')
, generateCaptcha = require(__dirname+'/../../helpers/captcha/captchagenerate.js') , generateCaptcha = require(__dirname+'/../../helpers/captcha/captchagenerate.js')
, { secureCookies } = require(__dirname+'/../../configs/main.json')
, production = process.env.NODE_ENV === 'production'; , production = process.env.NODE_ENV === 'production';
module.exports = async (req, res, next) => { module.exports = async (req, res, next) => {
@ -26,7 +27,7 @@ module.exports = async (req, res, next) => {
return res return res
.cookie('captchaid', captchaId.toString(), { .cookie('captchaid', captchaId.toString(), {
'maxAge': 5*60*1000, //5 minute cookie 'maxAge': 5*60*1000, //5 minute cookie
'secure': production, 'secure': production && secureCookies,
'sameSite': 'strict' 'sameSite': 'strict'
}) })
.redirect(`/captcha/${captchaId}.jpg`); .redirect(`/captcha/${captchaId}.jpg`);

@ -55,7 +55,7 @@ const express = require('express')
saveUninitialized: false, saveUninitialized: false,
cookie: { cookie: {
httpOnly: true, httpOnly: true,
secure: production, secure: configs.secureCookies && production,
sameSite: 'strict', sameSite: 'strict',
} }
})); }));

Loading…
Cancel
Save