From 2fd40191032c8c67e760b94d168428299e1cfd01 Mon Sep 17 00:00:00 2001 From: prosolis <5590409+prosolis@users.noreply.github.com> Date: Sat, 20 Jun 2026 11:26:02 -0700 Subject: [PATCH] Let Authentik own forward-auth user emails; add forward-auth tests For SSO users the email address is the IdP match key, so allowing them to edit it in Veola orphaned the row on next sign-in. PostEmailPrefs now keeps the synced Authentik email for forward users (only the deal-alert and digest toggles stay editable); the settings form renders the field read-only with a Managed by Authentik note. Local break-glass users keep an editable field. Add forward-auth integration tests over the full Routes() chain: trusted proxy provisions an admin, untrusted peer's spoofed headers are ignored, role re-syncs per request, and the email-prefs round trip confirms a form cannot change a forward user's IdP email. --- internal/handlers/handlers_test.go | 219 +++++++++++++++++++++++++++++ internal/handlers/settings.go | 7 + templates/settings.templ | 16 ++- templates/settings_templ.go | 213 ++++++++++++++++------------ 4 files changed, 364 insertions(+), 91 deletions(-) diff --git a/internal/handlers/handlers_test.go b/internal/handlers/handlers_test.go index a3f8e46..ffbbb1c 100644 --- a/internal/handlers/handlers_test.go +++ b/internal/handlers/handlers_test.go @@ -4,7 +4,9 @@ import ( "context" "net/http" "net/http/httptest" + "net/url" "path/filepath" + "regexp" "strings" "testing" @@ -113,3 +115,220 @@ func TestLoginPageRenders(t *testing.T) { t.Fatalf("body missing
") + templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 61, "> Email me the weekly digest (Mondays) ") if templ_7745c5c3_Err != nil { return templ_7745c5c3_Err } if d.IsAdmin { - templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 58, "| Username | Role | Created | |||||||
|---|---|---|---|---|---|---|---|---|---|
| ")
+ if d.UserMsg != "" {
+ templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 65, " ")
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
var templ_7745c5c3_Var28 string
- templ_7745c5c3_Var28, templ_7745c5c3_Err = templ.JoinStringErrs(u.Username)
+ templ_7745c5c3_Var28, templ_7745c5c3_Err = templ.JoinStringErrs(d.UserMsg)
if templ_7745c5c3_Err != nil {
- return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/settings.templ`, Line: 238, Col: 24}
+ return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/settings.templ`, Line: 236, Col: 37}
}
_, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var28))
if templ_7745c5c3_Err != nil {
return templ_7745c5c3_Err
}
- templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 65, " | ")
+ templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 66, "")
+ if templ_7745c5c3_Err != nil {
+ return templ_7745c5c3_Err
+ }
+ }
+ templ_7745c5c3_Err = templruntime.WriteString(templ_7745c5c3_Buffer, 67, "
|