From 0a58dd7f65dba3f92df3de167881f2aaa32a547c Mon Sep 17 00:00:00 2001 From: Fred KISSIE Date: Thu, 17 Sep 2026 22:59:20 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=9A=A7=20handle=20redirect?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.go | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/main.go b/main.go index f40594a..52fd8f9 100644 --- a/main.go +++ b/main.go @@ -101,6 +101,7 @@ type VerifyResponse struct { HeaderAuthChallenged bool `json:"headerAuthChallenged"` Valid bool `json:"valid"` RedirectURL *string `json:"redirectUrl"` + RedirectPermanent *bool `json:"redirectPermanent"` UserId *string `json:"userId,omitempty"` DontStripSession bool `json:"dontStripSession,omitempty"` Username *string `json:"username,omitempty"` @@ -347,8 +348,16 @@ func (p *Badger) ServeHTTP(rw http.ResponseWriter, req *http.Request) { } if result.Data.RedirectURL != nil && *result.Data.RedirectURL != "" { - fmt.Println("Badger: Redirecting to", *result.Data.RedirectURL) - http.Redirect(rw, req, *result.Data.RedirectURL, http.StatusFound) + status := http.StatusFound + if result.Data.RedirectPermanent != nil { + if *result.Data.RedirectPermanent { + status = http.StatusPermanentRedirect + } else { + status = http.StatusTemporaryRedirect + } + } + fmt.Println("Badger: Redirecting to", *result.Data.RedirectURL, "with status", status) + http.Redirect(rw, req, *result.Data.RedirectURL, status) return }