fix: 移除CheckExtValidRequest检查旧token
This commit is contained in:
@@ -189,13 +189,13 @@ func ExtDatabaseExecSQL(w http.ResponseWriter, r *http.Request) {
|
|||||||
log.Debug("ExtDatabaseExecSQL processing... ")
|
log.Debug("ExtDatabaseExecSQL processing... ")
|
||||||
|
|
||||||
var sql []string
|
var sql []string
|
||||||
var err error
|
// var err error
|
||||||
|
|
||||||
_, err = services.CheckExtValidRequest(w, r)
|
// _, err = services.CheckExtValidRequest(w, r)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
log.Error("Request error:", err)
|
// log.Error("Request error:", err)
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
|
|
||||||
//vars := mux.Vars(r)
|
//vars := mux.Vars(r)
|
||||||
//tblName := vars["objectTypeValue"]
|
//tblName := vars["objectTypeValue"]
|
||||||
@@ -250,11 +250,11 @@ func ExtDatabaseGetData(w http.ResponseWriter, r *http.Request) {
|
|||||||
log.Debug("ExtDatabaseGetData processing... ")
|
log.Debug("ExtDatabaseGetData processing... ")
|
||||||
|
|
||||||
var sql []string
|
var sql []string
|
||||||
token, err := services.CheckExtValidRequest(w, r)
|
// token, err := services.CheckExtValidRequest(w, r)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
log.Error("Request error:", err)
|
// log.Error("Request error:", err)
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
|
|
||||||
pack := "dbrest"
|
pack := "dbrest"
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
@@ -262,7 +262,7 @@ 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, module:%s, dbname:%s, tbname:%s, pack:%s", token, r.Method, module, dbname, tbname, pack)
|
log.Debugf("method:%s, module:%s, dbname:%s, tbname:%s, pack:%s", 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 {
|
||||||
@@ -296,12 +296,11 @@ func ExtDatabaseGetData(w http.ResponseWriter, r *http.Request) {
|
|||||||
for i, s := range sql {
|
for i, s := range sql {
|
||||||
log.Tracef("SQL[%d]: %s", i, sql[i])
|
log.Tracef("SQL[%d]: %s", i, sql[i])
|
||||||
|
|
||||||
rows := make([]map[string]interface{}, 0)
|
|
||||||
mapRows := make(map[string]interface{})
|
mapRows := make(map[string]interface{})
|
||||||
|
|
||||||
if s != "" {
|
if s != "" {
|
||||||
// err = XEngine.SQL(s).Find(&rows)
|
// err = XEngine.SQL(s).Find(&rows)
|
||||||
if IsQuerySQL(s) == false {
|
if !IsQuerySQL(s) {
|
||||||
services.ResponseNotAcceptable406QuerySQLError(w)
|
services.ResponseNotAcceptable406QuerySQLError(w)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -311,7 +310,7 @@ func ExtDatabaseGetData(w http.ResponseWriter, r *http.Request) {
|
|||||||
querySQL = querySQL + " " + ls
|
querySQL = querySQL + " " + ls
|
||||||
}
|
}
|
||||||
log.Debug("querySQL:", querySQL)
|
log.Debug("querySQL:", querySQL)
|
||||||
rows, err = DbClient.XEngine.QueryInterface(querySQL)
|
rows, err := DbClient.XEngine.QueryInterface(querySQL)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("SQL failed:", err)
|
log.Error("SQL failed:", err)
|
||||||
services.ResponseInternalServerError500DatabaseOperationFailed(w)
|
services.ResponseInternalServerError500DatabaseOperationFailed(w)
|
||||||
@@ -333,11 +332,11 @@ func ExtDatabaseGetData(w http.ResponseWriter, r *http.Request) {
|
|||||||
func ExtDatabaseInsertData(w http.ResponseWriter, r *http.Request) {
|
func ExtDatabaseInsertData(w http.ResponseWriter, r *http.Request) {
|
||||||
log.Debug("ExtDatabaseInsertData processing... ")
|
log.Debug("ExtDatabaseInsertData processing... ")
|
||||||
|
|
||||||
token, err := services.CheckExtValidRequest(w, r)
|
// token, err := services.CheckExtValidRequest(w, r)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
log.Error("Request error:", err)
|
// log.Error("Request error:", err)
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
|
|
||||||
body, err := io.ReadAll(io.LimitReader(r.Body, global.RequestBodyMaxLen)) //io.LimitReader限制大小
|
body, err := io.ReadAll(io.LimitReader(r.Body, global.RequestBodyMaxLen)) //io.LimitReader限制大小
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -352,7 +351,7 @@ func ExtDatabaseInsertData(w http.ResponseWriter, r *http.Request) {
|
|||||||
tbname := vars["objectTypeValue"]
|
tbname := vars["objectTypeValue"]
|
||||||
pack := "dbrest"
|
pack := "dbrest"
|
||||||
|
|
||||||
log.Debugf("token:%s, method:%s, module:%s, dbname:%s, tbname:%s, pack:%s", token, r.Method, module, dbname, tbname, pack)
|
log.Debugf("method:%s, module:%s, dbname:%s, tbname:%s, pack:%s", 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 {
|
||||||
@@ -397,11 +396,11 @@ func ExtDatabaseInsertData(w http.ResponseWriter, r *http.Request) {
|
|||||||
func ExtDatabaseUpdateData(w http.ResponseWriter, r *http.Request) {
|
func ExtDatabaseUpdateData(w http.ResponseWriter, r *http.Request) {
|
||||||
log.Debug("ExtDatabaseUpdateData processing... ")
|
log.Debug("ExtDatabaseUpdateData processing... ")
|
||||||
|
|
||||||
token, err := services.CheckExtValidRequest(w, r)
|
// token, err := services.CheckExtValidRequest(w, r)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
log.Error("Request error:", err)
|
// log.Error("Request error:", err)
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
|
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
module := ""
|
module := ""
|
||||||
@@ -409,7 +408,7 @@ func ExtDatabaseUpdateData(w http.ResponseWriter, r *http.Request) {
|
|||||||
tbname := vars["objectTypeValue"]
|
tbname := vars["objectTypeValue"]
|
||||||
pack := "dbrest"
|
pack := "dbrest"
|
||||||
|
|
||||||
log.Debugf("token:%s, method:%s, module:%s, dbname:%s, tbname:%s, pack:%s", token, r.Method, module, dbname, tbname, pack)
|
log.Debugf("method:%s, module:%s, dbname:%s, tbname:%s, pack:%s", 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 {
|
||||||
@@ -461,11 +460,11 @@ func ExtDatabaseUpdateData(w http.ResponseWriter, r *http.Request) {
|
|||||||
func ExtDatabaseDeleteData(w http.ResponseWriter, r *http.Request) {
|
func ExtDatabaseDeleteData(w http.ResponseWriter, r *http.Request) {
|
||||||
log.Debug("ExtDatabaseDeleteData processing... ")
|
log.Debug("ExtDatabaseDeleteData processing... ")
|
||||||
|
|
||||||
token, err := services.CheckExtValidRequest(w, r)
|
// token, err := services.CheckExtValidRequest(w, r)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
log.Error("Request error:", err)
|
// log.Error("Request error:", err)
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
|
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
module := ""
|
module := ""
|
||||||
@@ -473,7 +472,7 @@ func ExtDatabaseDeleteData(w http.ResponseWriter, r *http.Request) {
|
|||||||
tbname := vars["objectTypeValue"]
|
tbname := vars["objectTypeValue"]
|
||||||
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("method:%s, module:%, dbname:%s, tbname:%s pack:%s", 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 {
|
||||||
|
|||||||
@@ -82,18 +82,18 @@ func InitDbClient(dbType, dbUser, dbPassword, dbHost, dbPort, dbName, dbParam st
|
|||||||
func ExtDatabaseBackupData(w http.ResponseWriter, r *http.Request) {
|
func ExtDatabaseBackupData(w http.ResponseWriter, r *http.Request) {
|
||||||
log.Debug("ExtDatabaseBackupData processing... ")
|
log.Debug("ExtDatabaseBackupData processing... ")
|
||||||
|
|
||||||
token, err := services.CheckExtValidRequest(w, r)
|
// token, err := services.CheckExtValidRequest(w, r)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
log.Error("Request error:", err)
|
// log.Error("Request error:", err)
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
|
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
module := vars["managementModule"]
|
module := vars["managementModule"]
|
||||||
dbname := vars["dataStorage"]
|
dbname := vars["dataStorage"]
|
||||||
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("method:%s, module:%s dbname:%s, tbname:%s pack:%s", 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)
|
||||||
|
|||||||
@@ -186,11 +186,11 @@ func PostMML2ToNF(w http.ResponseWriter, r *http.Request) {
|
|||||||
func PostMMLToNF(w http.ResponseWriter, r *http.Request) {
|
func PostMMLToNF(w http.ResponseWriter, r *http.Request) {
|
||||||
log.Debug("PostMMLToNF processing... ")
|
log.Debug("PostMMLToNF processing... ")
|
||||||
|
|
||||||
token, err := services.CheckExtValidRequest(w, r)
|
// token, err := services.CheckExtValidRequest(w, r)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
log.Error("Request error:", err)
|
// log.Error("Request error:", err)
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
// 经过测试,linux下,延时需要大于100ms
|
// 经过测试,linux下,延时需要大于100ms
|
||||||
// var TIME_DELAY_AFTER_WRITE time.Duration = 200
|
// var TIME_DELAY_AFTER_WRITE time.Duration = 200
|
||||||
// var TIME_DEAD_LINE time.Duration = 10
|
// var TIME_DEAD_LINE time.Duration = 10
|
||||||
@@ -214,8 +214,7 @@ func PostMMLToNF(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
log.Debug("neType:", neType, "neId", neId)
|
log.Debug("neType:", neType, "neId", neId)
|
||||||
|
|
||||||
log.Debugf("token:%s, method:%s, managementType:%s dbname:%s, tbname:%s pack:%s",
|
log.Debugf("method:%s, managementType:%s dbname:%s, tbname:%s pack:%s", r.Method, module, neType, neId[0], pack)
|
||||||
token, r.Method, module, neType, neId[0], pack)
|
|
||||||
|
|
||||||
var buf [20 * 1024]byte
|
var buf [20 * 1024]byte
|
||||||
//buf := make([]byte, 0)
|
//buf := make([]byte, 0)
|
||||||
@@ -250,7 +249,7 @@ func PostMMLToNF(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
neInfo := new(dborm.NeInfo)
|
neInfo := new(dborm.NeInfo)
|
||||||
neInfo, err = dborm.XormGetNeInfo(neType, neId[0])
|
neInfo, err := dborm.XormGetNeInfo(neType, neId[0])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("dborm.XormGetNeInfo is failed:", err)
|
log.Error("dborm.XormGetNeInfo is failed:", err)
|
||||||
services.ResponseInternalServerError500DatabaseOperationFailed(w)
|
services.ResponseInternalServerError500DatabaseOperationFailed(w)
|
||||||
@@ -631,11 +630,11 @@ func PostMMLToNF(w http.ResponseWriter, r *http.Request) {
|
|||||||
func PostMMLToOMC(w http.ResponseWriter, r *http.Request) {
|
func PostMMLToOMC(w http.ResponseWriter, r *http.Request) {
|
||||||
log.Debug("PostMMLToOMC processing... ")
|
log.Debug("PostMMLToOMC processing... ")
|
||||||
|
|
||||||
token, err := services.CheckExtValidRequest(w, r)
|
// token, err := services.CheckExtValidRequest(w, r)
|
||||||
if err != nil {
|
// if err != nil {
|
||||||
log.Error("Failed to CheckMmlValidRequest:", err)
|
// log.Error("Failed to CheckMmlValidRequest:", err)
|
||||||
return
|
// return
|
||||||
}
|
// }
|
||||||
|
|
||||||
params := r.URL.Query()
|
params := r.URL.Query()
|
||||||
neId := params["ne_id"]
|
neId := params["ne_id"]
|
||||||
@@ -646,7 +645,7 @@ func PostMMLToOMC(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
neInfo := new(dborm.NeInfo)
|
neInfo := new(dborm.NeInfo)
|
||||||
neInfo, err = dborm.XormGetNeInfo("OMC", neId[0])
|
neInfo, err := dborm.XormGetNeInfo("OMC", neId[0])
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error("dborm.XormGetNeInfo is failed:", err)
|
log.Error("dborm.XormGetNeInfo is failed:", err)
|
||||||
services.ResponseInternalServerError500DatabaseOperationFailed(w)
|
services.ResponseInternalServerError500DatabaseOperationFailed(w)
|
||||||
@@ -670,7 +669,7 @@ func PostMMLToOMC(w http.ResponseWriter, r *http.Request) {
|
|||||||
MmlHome: config.GetYamlConfig().MML.MmlHome,
|
MmlHome: config.GetYamlConfig().MML.MmlHome,
|
||||||
Limit: 50,
|
Limit: 50,
|
||||||
User: "",
|
User: "",
|
||||||
SessionToken: token, // 旧token
|
SessionToken: "", // 旧token
|
||||||
Authorization: r.Header.Get(tokenConst.HEADER_KEY), // 请求Token
|
Authorization: r.Header.Get(tokenConst.HEADER_KEY), // 请求Token
|
||||||
HttpUri: hostUri,
|
HttpUri: hostUri,
|
||||||
UserAgent: config.GetDefaultUserAgent(),
|
UserAgent: config.GetDefaultUserAgent(),
|
||||||
|
|||||||
Reference in New Issue
Block a user