diff --git a/Dockerfile b/Dockerfile index 8579674..f84e108 100644 --- a/Dockerfile +++ b/Dockerfile @@ -28,7 +28,8 @@ EXPOSE 8080 ENV EW_USERNAME=admin \ EW_PASSWORD=admin \ EW_DB=/data/machines.json \ - EW_PRODUCTIVE=true + EW_PRODUCTIVE=true \ + EW_FORCEINSECURECOOKIE=false ENTRYPOINT ["/bin/edgewol"] \ No newline at end of file diff --git a/compose.yml b/compose.yml index 9df7165..0211013 100644 --- a/compose.yml +++ b/compose.yml @@ -2,7 +2,6 @@ services: api: image: git.send.nrw/sendnrw/edge-wol:latest container_name: edgewol - restart: unless-stopped volumes: - /docker/edgewol/machines.json:/data/machines.json #labels: diff --git a/main.go b/main.go index ce4ecb4..d875d00 100644 --- a/main.go +++ b/main.go @@ -185,7 +185,12 @@ func generateSessionToken() string { func main() { // Determine DB path and load machines. hashedPassword = hashPassword(password) - dbPath = GetENV("EW_DB", "/data/machines.json") + if productive { + dbPath = GetENV("EW_DB", "/data/machines.json") + } else { + dbPath = "./machines.json" + } + loadMachines() // Save on SIGINT/SIGTERM. @@ -223,13 +228,25 @@ func main() { // Speichere Session sessionStore[token] = user + var envSecure bool + if productive { + var forceInsecure bool = Enabled("EW_FORCEINSECURECOOKIE", false) + if forceInsecure { + envSecure = r.TLS != nil + } else { + envSecure = true + } + } else { + envSecure = r.TLS != nil + } + // Cookie setzen http.SetCookie(w, &http.Cookie{ Name: "session", Value: token, Path: "/", HttpOnly: true, - Secure: true, + Secure: envSecure, SameSite: http.SameSiteLaxMode, })