permission
This commit is contained in:
@@ -261,19 +261,19 @@ func ExtDatabaseGetData(w http.ResponseWriter, r *http.Request) {
|
|||||||
dbname := vars["elementTypeValue"]
|
dbname := vars["elementTypeValue"]
|
||||||
tbname := vars["objectTypeValue"]
|
tbname := vars["objectTypeValue"]
|
||||||
|
|
||||||
log.Debugf("token:%s, method:%s, dbname:%s, tbname:%s", token, r.Method, module, dbname, tbname, pack)
|
log.Debugf("token:%s, method:%s, module:%s, dbname:%s, tbname:%s, pack:%s", token, r.Method, module, dbname, tbname, pack)
|
||||||
|
|
||||||
exist, err := services.CheckUserPermission(token, strings.ToLower(r.Method), module, dbname, tbname, pack)
|
// exist, err := services.CheckUserPermission(token, strings.ToLower(r.Method), module, dbname, tbname, pack)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
log.Error("Failed to get permission:", err)
|
// log.Error("Failed to get permission:", err)
|
||||||
services.ResponseForbidden403NotPermission(w)
|
// services.ResponseForbidden403NotPermission(w)
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
if !exist {
|
// if !exist {
|
||||||
log.Error("Not permission!")
|
// log.Error("Not permission!")
|
||||||
services.ResponseForbidden403NotPermission(w)
|
// services.ResponseForbidden403NotPermission(w)
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
|
|
||||||
sql = GetUriSQLArray(r)
|
sql = GetUriSQLArray(r)
|
||||||
// select as must, todo ...
|
// select as must, todo ...
|
||||||
@@ -351,18 +351,19 @@ func ExtDatabaseInsertData(w http.ResponseWriter, r *http.Request) {
|
|||||||
tbname := vars["objectTypeValue"]
|
tbname := vars["objectTypeValue"]
|
||||||
pack := "dbrest"
|
pack := "dbrest"
|
||||||
|
|
||||||
log.Debugf("token:%s, method:%s, dbname:%s, tbname:%s pack:%s", token, r.Method, module, dbname, tbname, pack)
|
log.Debugf("token:%s, method:%s, module:%s, dbname:%s, tbname:%s, pack:%s", token, r.Method, module, dbname, tbname, pack)
|
||||||
exist, err := services.CheckUserPermission(token, strings.ToLower(r.Method), module, dbname, tbname, pack)
|
|
||||||
if err != nil {
|
// exist, err := services.CheckUserPermission(token, strings.ToLower(r.Method), module, dbname, tbname, pack)
|
||||||
log.Error("Failed to get permission:", err)
|
// if err != nil {
|
||||||
services.ResponseForbidden403NotPermission(w)
|
// log.Error("Failed to get permission:", err)
|
||||||
return
|
// services.ResponseForbidden403NotPermission(w)
|
||||||
}
|
// return
|
||||||
if !exist {
|
// }
|
||||||
log.Error("permission deny!")
|
// if !exist {
|
||||||
services.ResponseForbidden403NotPermission(w)
|
// log.Error("permission deny!")
|
||||||
return
|
// services.ResponseForbidden403NotPermission(w)
|
||||||
}
|
// return
|
||||||
|
// }
|
||||||
|
|
||||||
log.Debug("Request body:", string(body), "dataObject:", tbname)
|
log.Debug("Request body:", string(body), "dataObject:", tbname)
|
||||||
insertData := make(map[string]interface{})
|
insertData := make(map[string]interface{})
|
||||||
@@ -407,18 +408,19 @@ func ExtDatabaseUpdateData(w http.ResponseWriter, r *http.Request) {
|
|||||||
tbname := vars["objectTypeValue"]
|
tbname := vars["objectTypeValue"]
|
||||||
pack := "dbrest"
|
pack := "dbrest"
|
||||||
|
|
||||||
log.Debugf("token:%s, method:%s, dbname:%s, tbname:%s pack:%s", token, r.Method, module, dbname, tbname, pack)
|
log.Debugf("token:%s, method:%s, module:%s, dbname:%s, tbname:%s, pack:%s", token, r.Method, module, dbname, tbname, pack)
|
||||||
exist, err := services.CheckUserPermission(token, strings.ToLower(r.Method), module, dbname, tbname, pack)
|
|
||||||
if err != nil {
|
// exist, err := services.CheckUserPermission(token, strings.ToLower(r.Method), module, dbname, tbname, pack)
|
||||||
log.Error("Failed to get permission:", err)
|
// if err != nil {
|
||||||
services.ResponseForbidden403NotPermission(w)
|
// log.Error("Failed to get permission:", err)
|
||||||
return
|
// services.ResponseForbidden403NotPermission(w)
|
||||||
}
|
// return
|
||||||
if !exist {
|
// }
|
||||||
log.Error("Not permission!")
|
// if !exist {
|
||||||
services.ResponseForbidden403NotPermission(w)
|
// log.Error("Not permission!")
|
||||||
return
|
// services.ResponseForbidden403NotPermission(w)
|
||||||
}
|
// return
|
||||||
|
// }
|
||||||
|
|
||||||
body, err := io.ReadAll(io.LimitReader(r.Body, global.RequestBodyMaxLen))
|
body, err := io.ReadAll(io.LimitReader(r.Body, global.RequestBodyMaxLen))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -471,17 +473,18 @@ func ExtDatabaseDeleteData(w http.ResponseWriter, r *http.Request) {
|
|||||||
pack := "dbreset"
|
pack := "dbreset"
|
||||||
|
|
||||||
log.Debugf("token:%s, method:%s, module:%, dbname:%s, tbname:%s pack:%s", token, r.Method, module, dbname, tbname, pack)
|
log.Debugf("token:%s, method:%s, module:%, dbname:%s, tbname:%s pack:%s", token, r.Method, module, dbname, tbname, pack)
|
||||||
exist, err := services.CheckUserPermission(token, strings.ToLower(r.Method), module, dbname, tbname, pack)
|
|
||||||
if err != nil {
|
// exist, err := services.CheckUserPermission(token, strings.ToLower(r.Method), module, dbname, tbname, pack)
|
||||||
log.Error("Failed to get permission:", err)
|
// if err != nil {
|
||||||
services.ResponseForbidden403NotPermission(w)
|
// log.Error("Failed to get permission:", err)
|
||||||
return
|
// services.ResponseForbidden403NotPermission(w)
|
||||||
}
|
// return
|
||||||
if !exist {
|
// }
|
||||||
log.Error("Not permission!")
|
// if !exist {
|
||||||
services.ResponseForbidden403NotPermission(w)
|
// log.Error("Not permission!")
|
||||||
return
|
// services.ResponseForbidden403NotPermission(w)
|
||||||
}
|
// return
|
||||||
|
// }
|
||||||
|
|
||||||
wc := services.GetUriLocString(r)
|
wc := services.GetUriLocString(r)
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"net/http"
|
"net/http"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"strings"
|
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"ems.agt/lib/global"
|
"ems.agt/lib/global"
|
||||||
@@ -96,17 +95,17 @@ func ExtDatabaseBackupData(w http.ResponseWriter, r *http.Request) {
|
|||||||
tbname := vars["dataObject"]
|
tbname := vars["dataObject"]
|
||||||
pack := "lm"
|
pack := "lm"
|
||||||
log.Debugf("token:%s, method:%s, module:%s dbname:%s, tbname:%s pack:%s", token, r.Method, module, dbname, tbname, pack)
|
log.Debugf("token:%s, method:%s, module:%s dbname:%s, tbname:%s pack:%s", token, r.Method, module, dbname, tbname, pack)
|
||||||
exist, err := services.CheckUserPermission(token, strings.ToLower(r.Method), module, dbname, tbname, pack)
|
// exist, err := services.CheckUserPermission(token, strings.ToLower(r.Method), module, dbname, tbname, pack)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
log.Error("Failed to get permission:", err)
|
// log.Error("Failed to get permission:", err)
|
||||||
services.ResponseForbidden403NotPermission(w)
|
// services.ResponseForbidden403NotPermission(w)
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
if !exist {
|
// if !exist {
|
||||||
log.Error("permission deny!")
|
// log.Error("permission deny!")
|
||||||
services.ResponseForbidden403NotPermission(w)
|
// services.ResponseForbidden403NotPermission(w)
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
|
|
||||||
var sql string
|
var sql string
|
||||||
var filePath string
|
var filePath string
|
||||||
|
|||||||
@@ -76,27 +76,27 @@ func PostMMLToNF(w http.ResponseWriter, r *http.Request) {
|
|||||||
var n int
|
var n int
|
||||||
var mmlResult []string
|
var mmlResult []string
|
||||||
|
|
||||||
exist, err := services.CheckUserPermission(token, strings.ToLower(r.Method), module, neType, neId[0], pack)
|
// exist, err := services.CheckUserPermission(token, strings.ToLower(r.Method), module, neType, neId[0], pack)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
log.Error("Failed to get permission:", err)
|
// log.Error("Failed to get permission:", err)
|
||||||
errMsg := fmt.Sprintf("RetCode = -1 operation failed: do not have the operation permissions")
|
// errMsg := fmt.Sprintf("RetCode = -1 operation failed: do not have the operation permissions")
|
||||||
log.Error(errMsg)
|
// log.Error(errMsg)
|
||||||
mmlResult = append(mmlResult, errMsg)
|
// mmlResult = append(mmlResult, errMsg)
|
||||||
response := Response{mmlResult}
|
// response := Response{mmlResult}
|
||||||
services.ResponseWithJson(w, http.StatusOK, response)
|
// services.ResponseWithJson(w, http.StatusOK, response)
|
||||||
//services.ResponseForbidden403NotPermission(w)
|
// //services.ResponseForbidden403NotPermission(w)
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
if !exist {
|
// if !exist {
|
||||||
log.Error("Not permission!")
|
// log.Error("Not permission!")
|
||||||
errMsg := fmt.Sprintf("RetCode = -1 operation failed: do not have the operation permissions")
|
// errMsg := fmt.Sprintf("RetCode = -1 operation failed: do not have the operation permissions")
|
||||||
log.Error(errMsg)
|
// log.Error(errMsg)
|
||||||
mmlResult = append(mmlResult, errMsg)
|
// mmlResult = append(mmlResult, errMsg)
|
||||||
response := Response{mmlResult}
|
// response := Response{mmlResult}
|
||||||
services.ResponseWithJson(w, http.StatusOK, response)
|
// services.ResponseWithJson(w, http.StatusOK, response)
|
||||||
//services.ResponseForbidden403NotPermission(w)
|
// //services.ResponseForbidden403NotPermission(w)
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
|
|
||||||
if strings.ToLower(neType) == "omc" {
|
if strings.ToLower(neType) == "omc" {
|
||||||
PostMMLToOMC(w, r)
|
PostMMLToOMC(w, r)
|
||||||
|
|||||||
Reference in New Issue
Block a user