aboutsummaryrefslogtreecommitdiff
path: root/weed/admin/dash/middleware.go
diff options
context:
space:
mode:
authorChris Lu <chrislusf@users.noreply.github.com>2025-07-01 01:28:09 -0700
committerGitHub <noreply@github.com>2025-07-01 01:28:09 -0700
commit1defee3d682d86c7e0cbc7db7ebdb9cae872a471 (patch)
treedae266bee79c36a74214a47d3d9e9274b322d49d /weed/admin/dash/middleware.go
parente5adc3872a79e062826a387e1e2bb68196f14014 (diff)
downloadseaweedfs-1defee3d682d86c7e0cbc7db7ebdb9cae872a471.tar.xz
seaweedfs-1defee3d682d86c7e0cbc7db7ebdb9cae872a471.zip
Add admin component (#6928)
* init version * relocate * add s3 bucket link * refactor handlers into weed/admin folder * fix login logout * adding favicon * remove fall back to http get topology * grpc dial option, disk total capacity * show filer count * fix each volume disk usage * add filers to dashboard * adding hosts, volumes, collections * refactor code and menu * remove "refresh" button * fix data for collections * rename cluster hosts into volume servers * add masters, filers * reorder * adding file browser * create folder and upload files * add filer version, created at time * remove mock data * remove fields * fix submenu item highlighting * fix bucket creation * purge files * delete multiple * fix bucket creation * remove region from buckets * add object store with buckets and users * rendering permission * refactor * get bucket objects and size * link to file browser * add file size and count for collections page * paginate the volumes * fix possible SSRF https://github.com/seaweedfs/seaweedfs/pull/6928/checks?check_run_id=45108469801 * Update weed/command/admin.go Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update weed/command/admin.go Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * fix build * import * remove filer CLI option * remove filer option * remove CLI options --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Diffstat (limited to 'weed/admin/dash/middleware.go')
-rw-r--r--weed/admin/dash/middleware.go27
1 files changed, 27 insertions, 0 deletions
diff --git a/weed/admin/dash/middleware.go b/weed/admin/dash/middleware.go
new file mode 100644
index 000000000..ce538d7ca
--- /dev/null
+++ b/weed/admin/dash/middleware.go
@@ -0,0 +1,27 @@
+package dash
+
+import (
+ "net/http"
+
+ "github.com/gin-contrib/sessions"
+ "github.com/gin-gonic/gin"
+)
+
+// RequireAuth checks if user is authenticated
+func RequireAuth() gin.HandlerFunc {
+ return func(c *gin.Context) {
+ session := sessions.Default(c)
+ authenticated := session.Get("authenticated")
+ username := session.Get("username")
+
+ if authenticated != true || username == nil {
+ c.Redirect(http.StatusTemporaryRedirect, "/login")
+ c.Abort()
+ return
+ }
+
+ // Set username in context for use in handlers
+ c.Set("username", username)
+ c.Next()
+ }
+}