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 \
|
ENV EW_USERNAME=admin \
|
||||||
EW_PASSWORD=admin \
|
EW_PASSWORD=admin \
|
||||||
EW_DB=/data/machines.json \
|
EW_DB=/data/machines.json \
|
||||||
EW_PRODUCTIVE=true
|
EW_PRODUCTIVE=true \
|
||||||
|
EW_FORCEINSECURECOOKIE=false
|
||||||
|
|
||||||
|
|
||||||
ENTRYPOINT ["/bin/edgewol"]
|
ENTRYPOINT ["/bin/edgewol"]
|
@@ -2,7 +2,6 @@ services:
|
|||||||
api:
|
api:
|
||||||
image: git.send.nrw/sendnrw/edge-wol:latest
|
image: git.send.nrw/sendnrw/edge-wol:latest
|
||||||
container_name: edgewol
|
container_name: edgewol
|
||||||
restart: unless-stopped
|
|
||||||
volumes:
|
volumes:
|
||||||
- /docker/edgewol/machines.json:/data/machines.json
|
- /docker/edgewol/machines.json:/data/machines.json
|
||||||
#labels:
|
#labels:
|
||||||
|
19
main.go
19
main.go
@@ -185,7 +185,12 @@ func generateSessionToken() string {
|
|||||||
func main() {
|
func main() {
|
||||||
// Determine DB path and load machines.
|
// Determine DB path and load machines.
|
||||||
hashedPassword = hashPassword(password)
|
hashedPassword = hashPassword(password)
|
||||||
|
if productive {
|
||||||
dbPath = GetENV("EW_DB", "/data/machines.json")
|
dbPath = GetENV("EW_DB", "/data/machines.json")
|
||||||
|
} else {
|
||||||
|
dbPath = "./machines.json"
|
||||||
|
}
|
||||||
|
|
||||||
loadMachines()
|
loadMachines()
|
||||||
|
|
||||||
// Save on SIGINT/SIGTERM.
|
// Save on SIGINT/SIGTERM.
|
||||||
@@ -223,13 +228,25 @@ func main() {
|
|||||||
// Speichere Session
|
// Speichere Session
|
||||||
sessionStore[token] = user
|
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
|
// Cookie setzen
|
||||||
http.SetCookie(w, &http.Cookie{
|
http.SetCookie(w, &http.Cookie{
|
||||||
Name: "session",
|
Name: "session",
|
||||||
Value: token,
|
Value: token,
|
||||||
Path: "/",
|
Path: "/",
|
||||||
HttpOnly: true,
|
HttpOnly: true,
|
||||||
Secure: true,
|
Secure: envSecure,
|
||||||
SameSite: http.SameSiteLaxMode,
|
SameSite: http.SameSiteLaxMode,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user