summaryrefslogtreecommitdiff
path: root/middleware/auth.go
diff options
context:
space:
mode:
Diffstat (limited to 'middleware/auth.go')
-rw-r--r--middleware/auth.go5
1 files changed, 4 insertions, 1 deletions
diff --git a/middleware/auth.go b/middleware/auth.go
index 45fa864..e4f096b 100644
--- a/middleware/auth.go
+++ b/middleware/auth.go
@@ -52,7 +52,10 @@ func SessionAuth(next http.Handler) http.Handler {
return
}
+ // Add user info to context and headers for downstream handlers
ctx := context.WithValue(r.Context(), types.SessionDataContextKey, user)
+ r.Header.Set("X-Username", user.Username)
+ r.Header.Set("X-User-Role", user.Role)
next.ServeHTTP(w, r.WithContext(ctx))
})
}
@@ -151,4 +154,4 @@ func AdminMiddleware(next http.Handler) http.Handler {
logging.SecurityLog.Info("ADMIN ACCESS GRANTED", "user", user.Username, "path", r.URL.Path, "ip", ip)
next.ServeHTTP(w, r)
})
-}
+} \ No newline at end of file