Sfoglia il codice sorgente

Fixed user list bug

tobychui 3 anni fa
parent
commit
b531c0cce4
3 ha cambiato i file con 42 aggiunte e 12 eliminazioni
  1. 25 0
      documents/arozdfs draft.md
  2. 0 0
      test.bat
  3. 17 12
      user.go

+ 25 - 0
documents/arozdfs draft.md

@@ -0,0 +1,25 @@
+## Arozdfsv2 Proposal
+
+This document record the design decision and the design architure of the Arozdfsv2
+
+### Development Goal
+
+The goal for the arozdfs is similar to the v1 that provides 
+
+- No single point of failure for storage cluster
+- At max 2 node can fail within a clueter group before any files started to have access fail conditions
+- Speed for file access is either the max value of client up/download speed OR following the ```0.8 * number of nodes * nodes average etherenet bandwidth``` rule
+- System should be able to deploy on amd64, arm64, armv7 and MIPS based processors, with no runtime dependncies, 3rd party dependencies or WAN access requirements.
+- System should require minimum manal setup
+  - (Default Enabled) Use MDNS for scanning instead if asking the user to type in IP address of the data node server
+  - Use common token for authentication, but also support using username and password
+  - Chunk duplication can be set between 2 to 4 (duplicates per chunk)
+  - One click fail disk restore
+  - Automatic Shuffle when new data node is added
+  - Atutomatic sync when new name node is added
+  - Automatic detach and chunk relocation when node failed
+  - Automatic user notification when critical node failure number reached (< 3 nodes in cluster OR relocated chunks cannot be fitted into the remaining nodes)
+- Automatic Health Check
+  - For a fixed interval, check all blocks within the system is valid
+  - SMART check intergration for disk health check (if enabled via startup paramters)
+  - 

+ 0 - 0
test.bat


+ 17 - 12
user.go

@@ -29,17 +29,19 @@ func UserSystemInit() {
 	}
 	userHandler = uh
 
-	router := prout.NewModuleRouter(prout.RouterOption{
-		ModuleName:  "System Settings",
-		AdminOnly:   false,
-		UserHandler: userHandler,
-		DeniedHandler: func(w http.ResponseWriter, r *http.Request) {
-			sendErrorResponse(w, "Permission Denied")
-		},
-	})
+	/*
+		router := prout.NewModuleRouter(prout.RouterOption{
+			ModuleName:  "System Settings",
+			AdminOnly:   false,
+			UserHandler: userHandler,
+			DeniedHandler: func(w http.ResponseWriter, r *http.Request) {
+				sendErrorResponse(w, "Permission Denied")
+			},
+		})
+	*/
 
 	//Create Endpoint Listeners
-	router.HandleFunc("/system/users/list", user_handleList)
+	http.HandleFunc("/system/users/list", user_handleList)
 
 	//Everyone logged in should have permission to view their profile and change their password
 	http.HandleFunc("/system/users/userinfo", func(w http.ResponseWriter, r *http.Request) {
@@ -373,7 +375,7 @@ func user_handleList(w http.ResponseWriter, r *http.Request) {
 		sendErrorResponse(w, "User not logged in")
 		return
 	}
-	if userinfo.IsAdmin() == true {
+	if userinfo.IsAdmin() {
 		entries, _ := sysdb.ListTable("auth")
 		var results [][]interface{}
 		for _, keypairs := range entries {
@@ -395,9 +397,12 @@ func user_handleList(w http.ResponseWriter, r *http.Request) {
 
 		jsonString, _ := json.Marshal(results)
 		sendJSONResponse(w, string(jsonString))
+	} else if authAgent.CheckAuth(r) {
+		allUserNames := authAgent.ListUsers()
+		js, _ := json.Marshal(allUserNames)
+		sendJSONResponse(w, string(js))
 	} else {
-		sendErrorResponse(w, "Permission denied")
-		return
+		sendErrorResponse(w, "Permission Denied")
 	}
 }