mirror of
https://github.com/zedeus/nitter.git
synced 2024-12-13 03:26:30 +00:00
Set cookie security using useHttps config option
This commit is contained in:
parent
5f2127fb52
commit
c2413ccfdd
3 changed files with 4 additions and 2 deletions
|
@ -15,6 +15,7 @@ proc getConfig*(path: string): Config =
|
||||||
Config(
|
Config(
|
||||||
address: cfg.get("Server", "address", "0.0.0.0"),
|
address: cfg.get("Server", "address", "0.0.0.0"),
|
||||||
port: cfg.get("Server", "port", 8080),
|
port: cfg.get("Server", "port", 8080),
|
||||||
|
useHttps: cfg.get("Server", "https", true),
|
||||||
title: cfg.get("Server", "title", "Nitter"),
|
title: cfg.get("Server", "title", "Nitter"),
|
||||||
staticDir: cfg.get("Server", "staticDir", "./public"),
|
staticDir: cfg.get("Server", "staticDir", "./public"),
|
||||||
|
|
||||||
|
|
|
@ -89,13 +89,13 @@ routes:
|
||||||
post "/saveprefs":
|
post "/saveprefs":
|
||||||
var prefs = cookiePrefs()
|
var prefs = cookiePrefs()
|
||||||
genUpdatePrefs()
|
genUpdatePrefs()
|
||||||
setCookie("preferences", $prefs.id, daysForward(360), httpOnly=true, secure=true)
|
setCookie("preferences", $prefs.id, daysForward(360), httpOnly=true, secure=cfg.useHttps)
|
||||||
redirect("/")
|
redirect("/")
|
||||||
|
|
||||||
post "/resetprefs":
|
post "/resetprefs":
|
||||||
var prefs = cookiePrefs()
|
var prefs = cookiePrefs()
|
||||||
resetPrefs(prefs)
|
resetPrefs(prefs)
|
||||||
setCookie("preferences", $prefs.id, daysForward(360), httpOnly=true, secure=true)
|
setCookie("preferences", $prefs.id, daysForward(360), httpOnly=true, secure=cfg.useHttps)
|
||||||
redirect("/settings")
|
redirect("/settings")
|
||||||
|
|
||||||
get "/settings":
|
get "/settings":
|
||||||
|
|
|
@ -167,6 +167,7 @@ type
|
||||||
Config* = ref object
|
Config* = ref object
|
||||||
address*: string
|
address*: string
|
||||||
port*: int
|
port*: int
|
||||||
|
useHttps*: bool
|
||||||
title*: string
|
title*: string
|
||||||
staticDir*: string
|
staticDir*: string
|
||||||
cacheDir*: string
|
cacheDir*: string
|
||||||
|
|
Loading…
Reference in a new issue