diff --git a/src/main.go b/src/main.go index 2034490..43a65f5 100644 --- a/src/main.go +++ b/src/main.go @@ -7,6 +7,7 @@ import ( "fmt" "log/slog" "net/http" + "net/url" "os" "os/signal" "path/filepath" @@ -132,15 +133,14 @@ func main() { HttpOnly: true, SameSite: http.SameSiteLaxMode, }) - // Clear NextWks session and redirect to workspace + // Clear both NextWks and Authelia session cookies http.SetCookie(w, &http.Cookie{ - Name: "nextwks_session", - Value: "", - Path: "/", - Domain: cfg.OIDC.Domain, - MaxAge: -1, - HttpOnly: true, - SameSite: http.SameSiteLaxMode, + Name: "nextwks_session", Value: "", Path: "/", Domain: cfg.OIDC.Domain, + MaxAge: -1, HttpOnly: true, SameSite: http.SameSiteLaxMode, + }) + http.SetCookie(w, &http.Cookie{ + Name: "authelia_session", Value: "", Path: "/", Domain: domainFromURL(cfg.OIDC.IssuerURL), + MaxAge: -1, HttpOnly: true, SameSite: http.SameSiteLaxMode, }) http.Redirect(w, r, "/", http.StatusFound) }) @@ -240,3 +240,11 @@ func corsMiddleware(next http.Handler) http.Handler { next.ServeHTTP(w, r) }) } + +func domainFromURL(rawURL string) string { + u, err := url.Parse(rawURL) + if err != nil { + return "" + } + return u.Hostname() +}