Anpassung für Login-Problem bei Testverbindungen mit Cookie Secure=True. Umgebungsvariable EW_FORCEINSECURECOOKIE hinzugefügt. Wenn Produktiv und Var = True Dann Autoset Wenn False dann Secure! Wenn Produktiv = False Dann Autoset.
Some checks failed
release-tag / release-image (push) Successful in 4m33s
build-binaries / build (, arm, 7, linux) (push) Has been cancelled
build-binaries / build (, arm64, linux) (push) Has been cancelled
build-binaries / build (, amd64, linux) (push) Has been cancelled
build-binaries / build (.exe, amd64, windows) (push) Has been cancelled
build-binaries / release (push) Has been cancelled
Some checks failed
release-tag / release-image (push) Successful in 4m33s
build-binaries / build (, arm, 7, linux) (push) Has been cancelled
build-binaries / build (, arm64, linux) (push) Has been cancelled
build-binaries / build (, amd64, linux) (push) Has been cancelled
build-binaries / build (.exe, amd64, windows) (push) Has been cancelled
build-binaries / release (push) Has been cancelled
This commit is contained in:
@@ -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"]
|
@@ -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:
|
||||
|
19
main.go
19
main.go
@@ -185,7 +185,12 @@ func generateSessionToken() string {
|
||||
func main() {
|
||||
// Determine DB path and load machines.
|
||||
hashedPassword = hashPassword(password)
|
||||
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,
|
||||
})
|
||||
|
||||
|
Reference in New Issue
Block a user