summaryrefslogtreecommitdiffstats
path: root/web/middleware
diff options
context:
space:
mode:
authorLeonardo Bishop <me@leonardobishop.net>2026-01-16 18:45:03 +0000
committerLeonardo Bishop <me@leonardobishop.net>2026-01-16 18:45:03 +0000
commiteddd55bc5dcfe36d8a56645d4b7e2e49429a933c (patch)
tree3eaf75f72225004980e99bc4a848a0cf5f942090 /web/middleware
parente6cbb8415490524034561102b6c9f03e92e4dae7 (diff)
Cache /userinfo for a bit
Diffstat (limited to 'web/middleware')
-rw-r--r--web/middleware/auth.go5
1 files changed, 3 insertions, 2 deletions
diff --git a/web/middleware/auth.go b/web/middleware/auth.go
index c0257e2..5feccfe 100644
--- a/web/middleware/auth.go
+++ b/web/middleware/auth.go
@@ -6,6 +6,7 @@ import (
"html/template"
"log/slog"
"net/http"
+ "net/url"
"git.leonardobishop.net/instancer/pkg/auth"
"git.leonardobishop.net/instancer/pkg/session"
@@ -22,14 +23,14 @@ func MustAuthenticate(tmpl *template.Template, store *session.MemoryStore, authP
s := store.GetByToken(sessionCookie.Value)
if s == nil {
- http.Redirect(w, r, "/auth", http.StatusFound)
+ http.Redirect(w, r, "/auth?error="+url.QueryEscape("Session does not exist"), http.StatusFound)
return
}
err = authProvider.UpdateUserInfo(r.Context(), s)
if err != nil {
if errors.Is(err, auth.ErrInvalidToken) {
- http.Redirect(w, r, "/auth", http.StatusFound)
+ http.Redirect(w, r, "/auth?error="+url.QueryEscape("OIDC authentication has expired"), http.StatusFound)
return
}
slog.Error("error updating user info", "cause", err)