From 312aa388d4409210cfba7a76f6af4b83bc7fb056 Mon Sep 17 00:00:00 2001 From: cclohmar Date: Mon, 15 Jun 2026 08:24:13 +0000 Subject: [PATCH] feat(auth): custom logout page with Authelia sign-out and re-login button --- src/core/ui/logout.templ | 40 ++++++++++++++++++++++ src/core/ui/logout_templ.go | 66 +++++++++++++++++++++++++++++++++++++ src/main.go | 15 ++------- 3 files changed, 109 insertions(+), 12 deletions(-) create mode 100644 src/core/ui/logout.templ create mode 100644 src/core/ui/logout_templ.go diff --git a/src/core/ui/logout.templ b/src/core/ui/logout.templ new file mode 100644 index 0000000..042fc73 --- /dev/null +++ b/src/core/ui/logout.templ @@ -0,0 +1,40 @@ +package ui + +templ LogoutPage(authLogoutURL, workspaceURL string) { + + + + + + Logged Out — Next Workspace + + + +
+

Logged Out

+
✓ Session cleared
+

You have been logged out of Next Workspace. Your identity provider session will also be cleared.

+ Re-login + Sign out from Authelia +
+ + + +} diff --git a/src/core/ui/logout_templ.go b/src/core/ui/logout_templ.go new file mode 100644 index 0000000..3dd7e5c --- /dev/null +++ b/src/core/ui/logout_templ.go @@ -0,0 +1,66 @@ +// Code generated by templ - DO NOT EDIT. + +// templ: version: v0.3.1020 +package ui + +//lint:file-ignore SA4006 This context is only used if a nested component is present. + +import "github.com/a-h/templ" +import templruntime "github.com/a-h/templ/runtime" + +func LogoutPage(authLogoutURL, workspaceURL string) templ.Component { + return templruntime.GeneratedTemplate(func(templ_7745c5c3_Input templruntime.GeneratedComponentInput) (templ_7745c5c3_Err error) { + templ_7745c5c3_W, ctx := templ_7745c5c3_Input.Writer, templ_7745c5c3_Input.Context + if templ_7745c5c3_CtxErr := ctx.Err(); templ_7745c5c3_CtxErr != nil { + return templ_7745c5c3_CtxErr + } + templ_7745c5c3_Buffer, templ_7745c5c3_IsBuffer := templruntime.GetBuffer(templ_7745c5c3_W) + if !templ_7745c5c3_IsBuffer { + defer func() { + templ_7745c5c3_BufErr := templruntime.ReleaseBuffer(templ_7745c5c3_Buffer) + if templ_7745c5c3_Err == nil { + templ_7745c5c3_Err = templ_7745c5c3_BufErr + } + }() + } + ctx = templ.InitializeContext(ctx) + templ_7745c5c3_Var1 := templ.GetChildren(ctx) + if templ_7745c5c3_Var1 == nil { + templ_7745c5c3_Var1 = templ.NopComponent + } + ctx = templ.ClearChildren(ctx) + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 1, "Logged Out — Next Workspace

Logged Out

✓ Session cleared

You have been logged out of Next Workspace. Your identity provider session will also be cleared.

Re-login Sign out from Authelia
") + if templ_7745c5c3_Err != nil { + return templ_7745c5c3_Err + } + return nil + }) +} + +var _ = templruntime.GeneratedTemplate diff --git a/src/main.go b/src/main.go index ac89b52..9301859 100644 --- a/src/main.go +++ b/src/main.go @@ -123,23 +123,14 @@ func main() { mux.HandleFunc("GET /auth/callback", oidcHandler.Callback) mux.HandleFunc("POST /auth/callback", oidcHandler.Callback) mux.HandleFunc("GET /auth/logout", func(w http.ResponseWriter, r *http.Request) { - // Clear session cookie (with domain to match) - http.SetCookie(w, &http.Cookie{ - Name: "nextwks_session", - Value: "", - Path: "/", - Domain: cfg.OIDC.Domain, - MaxAge: -1, - HttpOnly: true, - SameSite: http.SameSiteLaxMode, - }) // Clear NextWks session cookie http.SetCookie(w, &http.Cookie{ Name: "nextwks_session", Value: "", Path: "/", Domain: cfg.OIDC.Domain, MaxAge: -1, HttpOnly: true, SameSite: http.SameSiteLaxMode, }) - // Redirect to workspace — no session means redirect to Authelia login - http.Redirect(w, r, "/", http.StatusFound) + authLogoutURL := fmt.Sprintf("%s/logout", cfg.OIDC.IssuerURL) + component := ui.LogoutPage(authLogoutURL, cfg.OIDC.RedirectURL) + component.Render(r.Context(), w) }) // --- Workspace launcher (public, but OIDC-protected) ---