perf: 移动features模块配置序列号结构体到be.ems/lib/config
This commit is contained in:
@@ -9,11 +9,11 @@ import (
|
|||||||
|
|
||||||
"github.com/go-resty/resty/v2"
|
"github.com/go-resty/resty/v2"
|
||||||
|
|
||||||
|
"be.ems/lib/config"
|
||||||
"be.ems/lib/dborm"
|
"be.ems/lib/dborm"
|
||||||
"be.ems/lib/log"
|
"be.ems/lib/log"
|
||||||
"be.ems/lib/oauth"
|
"be.ems/lib/oauth"
|
||||||
"be.ems/lib/services"
|
"be.ems/lib/services"
|
||||||
"be.ems/restagent/config"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|||||||
@@ -5,11 +5,11 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"be.ems/lib/config"
|
||||||
"be.ems/lib/core/ctx"
|
"be.ems/lib/core/ctx"
|
||||||
"be.ems/lib/dborm"
|
"be.ems/lib/dborm"
|
||||||
"be.ems/lib/log"
|
"be.ems/lib/log"
|
||||||
"be.ems/lib/services"
|
"be.ems/lib/services"
|
||||||
"be.ems/restagent/config"
|
|
||||||
neService "be.ems/src/modules/network_element/service"
|
neService "be.ems/src/modules/network_element/service"
|
||||||
wsService "be.ems/src/modules/ws/service"
|
wsService "be.ems/src/modules/ws/service"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -10,11 +10,11 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"be.ems/lib/config"
|
||||||
"be.ems/lib/dborm"
|
"be.ems/lib/dborm"
|
||||||
"be.ems/lib/global"
|
"be.ems/lib/global"
|
||||||
"be.ems/lib/log"
|
"be.ems/lib/log"
|
||||||
"be.ems/lib/services"
|
"be.ems/lib/services"
|
||||||
"be.ems/restagent/config"
|
|
||||||
tokenConst "be.ems/src/framework/constants/token"
|
tokenConst "be.ems/src/framework/constants/token"
|
||||||
neService "be.ems/src/modules/network_element/service"
|
neService "be.ems/src/modules/network_element/service"
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ package cm_omc
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
"be.ems/restagent/config"
|
"be.ems/lib/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|||||||
@@ -3,11 +3,11 @@ package cm
|
|||||||
import (
|
import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"be.ems/lib/config"
|
||||||
"be.ems/lib/core/ctx"
|
"be.ems/lib/core/ctx"
|
||||||
"be.ems/lib/global"
|
"be.ems/lib/global"
|
||||||
"be.ems/lib/log"
|
"be.ems/lib/log"
|
||||||
"be.ems/lib/services"
|
"be.ems/lib/services"
|
||||||
"be.ems/restagent/config"
|
|
||||||
|
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|||||||
@@ -10,11 +10,11 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"be.ems/lib/config"
|
||||||
"be.ems/lib/dborm"
|
"be.ems/lib/dborm"
|
||||||
"be.ems/lib/global"
|
"be.ems/lib/global"
|
||||||
"be.ems/lib/log"
|
"be.ems/lib/log"
|
||||||
"be.ems/lib/services"
|
"be.ems/lib/services"
|
||||||
"be.ems/restagent/config"
|
|
||||||
|
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,134 +0,0 @@
|
|||||||
package dbrest
|
|
||||||
|
|
||||||
import (
|
|
||||||
"archive/tar"
|
|
||||||
"compress/gzip"
|
|
||||||
"io"
|
|
||||||
"net/http"
|
|
||||||
"os"
|
|
||||||
"os/exec"
|
|
||||||
"path/filepath"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"be.ems/lib/core/conf"
|
|
||||||
"be.ems/lib/dborm"
|
|
||||||
"be.ems/lib/log"
|
|
||||||
"be.ems/lib/services"
|
|
||||||
"be.ems/restagent/config"
|
|
||||||
_ "github.com/go-sql-driver/mysql"
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
// 系统备份-数据库备份
|
|
||||||
UriDbBackup = config.DefaultUriPrefix + "/dataManagement/{apiVersion}/dbBackup"
|
|
||||||
CustomUriDbBackup = config.UriPrefix + "/dataManagement/{apiVersion}/dbBackup" // for external
|
|
||||||
|
|
||||||
// 系统备份-文件备份
|
|
||||||
UriConfBackup = config.DefaultUriPrefix + "/dataManagement/{apiVersion}/confBackup"
|
|
||||||
CustomUriConfBackup = config.UriPrefix + "/dataManagement/{apiVersion}/confBackup" // for external
|
|
||||||
|
|
||||||
)
|
|
||||||
|
|
||||||
// DbBackup 系统备份-数据库备份1
|
|
||||||
func DbBackup(w http.ResponseWriter, r *http.Request) {
|
|
||||||
dbConfigHost := conf.Get("database.host").(string)
|
|
||||||
dbConfigUser := conf.Get("database.user").(string)
|
|
||||||
dbConfigPassword := conf.Get("database.password").(string)
|
|
||||||
dbConfigBackup := conf.Get("database.backup").(string)
|
|
||||||
|
|
||||||
// 备份SQL文件路径
|
|
||||||
fileName := "database_backup_" + time.Now().Format("20060102150405") + ".sql"
|
|
||||||
backupFile := dbConfigBackup + "/" + fileName
|
|
||||||
|
|
||||||
// 执行mysqldump命令进行备份
|
|
||||||
cmd := exec.Command("mysqldump", "-u", dbConfigUser, "-p"+dbConfigPassword, "-h", dbConfigHost, "--all-databases", ">", backupFile)
|
|
||||||
err := cmd.Start()
|
|
||||||
if err != nil {
|
|
||||||
services.ResponseErrorWithJson(w, 400, err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// 备份结果
|
|
||||||
res, err := dborm.DbClient.XEngine.Exec("INSERT INTO `sys_backup`(`id`, `created_at`, `updated_at`, `backup_type`, `backup_way`, `name`, `path`) VALUES (null, ?, ?, '1', '0', ?, ?);", time.Now(), time.Now(), fileName, backupFile)
|
|
||||||
if err != nil {
|
|
||||||
services.ResponseErrorWithJson(w, 500, err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
services.ResponseWithJson(w, 200, res)
|
|
||||||
log.Info("Backup completed successfully.")
|
|
||||||
}
|
|
||||||
|
|
||||||
// 系统备份-文件备份0
|
|
||||||
func ConfBackup(w http.ResponseWriter, r *http.Request) {
|
|
||||||
dbConfigBackup := conf.Get("database.backup").(string)
|
|
||||||
etcDir := conf.Get("ne.omcdir").(string)
|
|
||||||
|
|
||||||
// 文件名
|
|
||||||
fileName := "conf_backup_" + time.Now().Format("20060102150405") + ".tar.gz"
|
|
||||||
backupFile := dbConfigBackup + "/" + fileName
|
|
||||||
|
|
||||||
err := createTarGz(etcDir, backupFile)
|
|
||||||
if err != nil {
|
|
||||||
services.ResponseErrorWithJson(w, 500, err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
// 备份结果
|
|
||||||
res, err := dborm.DbClient.XEngine.Exec("INSERT INTO `sys_backup`(`id`, `created_at`, `updated_at`, `backup_type`, `backup_way`, `name`, `path`) VALUES (null, ?, ?, '1', '0', ?, ?);", time.Now(), time.Now(), fileName, backupFile)
|
|
||||||
if err != nil {
|
|
||||||
services.ResponseErrorWithJson(w, 500, err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
services.ResponseWithJson(w, 200, res)
|
|
||||||
log.Info("Backup completed successfully.")
|
|
||||||
}
|
|
||||||
|
|
||||||
// 打压缩
|
|
||||||
func createTarGz(source, target string) error {
|
|
||||||
tarFile, err := os.Create(target)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
defer tarFile.Close()
|
|
||||||
|
|
||||||
gw := gzip.NewWriter(tarFile)
|
|
||||||
defer gw.Close()
|
|
||||||
|
|
||||||
tw := tar.NewWriter(gw)
|
|
||||||
defer tw.Close()
|
|
||||||
|
|
||||||
return filepath.Walk(source, func(path string, info os.FileInfo, err error) error {
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
header, err := tar.FileInfoHeader(info, "")
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
relPath, err := filepath.Rel(source, path)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
header.Name = relPath
|
|
||||||
|
|
||||||
if err := tw.WriteHeader(header); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if !info.Mode().IsRegular() {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
file, err := os.Open(path)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
defer file.Close()
|
|
||||||
|
|
||||||
_, err = io.Copy(tw, file)
|
|
||||||
return err
|
|
||||||
})
|
|
||||||
}
|
|
||||||
@@ -9,12 +9,12 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"be.ems/lib/config"
|
||||||
"be.ems/lib/core/ctx"
|
"be.ems/lib/core/ctx"
|
||||||
"be.ems/lib/dborm"
|
"be.ems/lib/dborm"
|
||||||
"be.ems/lib/global"
|
"be.ems/lib/global"
|
||||||
"be.ems/lib/log"
|
"be.ems/lib/log"
|
||||||
"be.ems/lib/services"
|
"be.ems/lib/services"
|
||||||
"be.ems/restagent/config"
|
|
||||||
|
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
"xorm.io/xorm"
|
"xorm.io/xorm"
|
||||||
|
|||||||
@@ -6,11 +6,11 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"be.ems/lib/config"
|
||||||
"be.ems/lib/core/ctx"
|
"be.ems/lib/core/ctx"
|
||||||
"be.ems/lib/dborm"
|
"be.ems/lib/dborm"
|
||||||
"be.ems/lib/log"
|
"be.ems/lib/log"
|
||||||
"be.ems/lib/services"
|
"be.ems/lib/services"
|
||||||
"be.ems/restagent/config"
|
|
||||||
"be.ems/src/framework/utils/parse"
|
"be.ems/src/framework/utils/parse"
|
||||||
neService "be.ems/src/modules/network_element/service"
|
neService "be.ems/src/modules/network_element/service"
|
||||||
wsService "be.ems/src/modules/ws/service"
|
wsService "be.ems/src/modules/ws/service"
|
||||||
|
|||||||
@@ -4,9 +4,9 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
|
"be.ems/lib/config"
|
||||||
"be.ems/lib/log"
|
"be.ems/lib/log"
|
||||||
"be.ems/lib/services"
|
"be.ems/lib/services"
|
||||||
"be.ems/restagent/config"
|
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -10,11 +10,11 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"be.ems/lib/config"
|
||||||
"be.ems/lib/dborm"
|
"be.ems/lib/dborm"
|
||||||
"be.ems/lib/global"
|
"be.ems/lib/global"
|
||||||
"be.ems/lib/log"
|
"be.ems/lib/log"
|
||||||
"be.ems/lib/services"
|
"be.ems/lib/services"
|
||||||
"be.ems/restagent/config"
|
|
||||||
"xorm.io/xorm"
|
"xorm.io/xorm"
|
||||||
|
|
||||||
"github.com/go-resty/resty/v2"
|
"github.com/go-resty/resty/v2"
|
||||||
|
|||||||
@@ -5,9 +5,9 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"be.ems/lib/config"
|
||||||
"be.ems/lib/dborm"
|
"be.ems/lib/dborm"
|
||||||
"be.ems/lib/log"
|
"be.ems/lib/log"
|
||||||
"be.ems/restagent/config"
|
|
||||||
|
|
||||||
"gopkg.in/gomail.v2"
|
"gopkg.in/gomail.v2"
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -8,9 +8,9 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"be.ems/lib/config"
|
||||||
"be.ems/lib/dborm"
|
"be.ems/lib/dborm"
|
||||||
"be.ems/lib/log"
|
"be.ems/lib/log"
|
||||||
"be.ems/restagent/config"
|
|
||||||
"github.com/linxGnu/gosmpp"
|
"github.com/linxGnu/gosmpp"
|
||||||
"github.com/linxGnu/gosmpp/data"
|
"github.com/linxGnu/gosmpp/data"
|
||||||
"github.com/linxGnu/gosmpp/pdu"
|
"github.com/linxGnu/gosmpp/pdu"
|
||||||
|
|||||||
@@ -8,17 +8,15 @@ import (
|
|||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"be.ems/lib/dborm"
|
|
||||||
|
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
g "github.com/gosnmp/gosnmp"
|
g "github.com/gosnmp/gosnmp"
|
||||||
|
|
||||||
|
"be.ems/lib/config"
|
||||||
"be.ems/lib/global"
|
"be.ems/lib/global"
|
||||||
"be.ems/lib/log"
|
"be.ems/lib/log"
|
||||||
"be.ems/lib/oauth"
|
"be.ems/lib/oauth"
|
||||||
"be.ems/lib/services"
|
"be.ems/lib/services"
|
||||||
"be.ems/lib/session"
|
"be.ems/lib/session"
|
||||||
"be.ems/restagent/config"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var TodoList []stTodo
|
var TodoList []stTodo
|
||||||
@@ -88,11 +86,7 @@ func IsWrongOAuthInfo(oAuthBody OAuthBody) bool {
|
|||||||
func IsValidOAuthUri(r *http.Request) bool {
|
func IsValidOAuthUri(r *http.Request) bool {
|
||||||
vars := mux.Vars(r)
|
vars := mux.Vars(r)
|
||||||
Uri := vars["apiCategory"] + "/" + vars["apiVersion"] // 获取Uri
|
Uri := vars["apiCategory"] + "/" + vars["apiVersion"] // 获取Uri
|
||||||
if Uri != "securityManagement/v1" {
|
return Uri == "securityManagement/v1"
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func IsVallidContentType(r *http.Request) bool {
|
func IsVallidContentType(r *http.Request) bool {
|
||||||
@@ -164,26 +158,13 @@ func LoginFromOMC(w http.ResponseWriter, r *http.Request) {
|
|||||||
services.ResponseBadRequest400IncorrectLogin(w)
|
services.ResponseBadRequest400IncorrectLogin(w)
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
validUser, changePassword, _ := dborm.XormCheckLoginUser(oAuthBody.UserName,
|
// response 400-4
|
||||||
oAuthBody.Value, config.GetYamlConfig().Auth.Crypt)
|
log.Error("Authentication failed, mismatch user or password")
|
||||||
if validUser {
|
|
||||||
// plist := config.GetPermissionFromConfig(oAuthBody.UserName, oAuthBody.GrantType)
|
|
||||||
plist := []bool{true, true, true, true}
|
|
||||||
log.Debug("Permission list:", plist)
|
|
||||||
|
|
||||||
token := globalSession.NewSession(w, r, plist)
|
services.ResponseBadRequest400IncorrectLogin(w)
|
||||||
services.ResponseStatusOK200Login(w, token, changePassword)
|
|
||||||
} else {
|
|
||||||
// response 400-4
|
|
||||||
log.Error("Authentication failed, mismatch user or password")
|
|
||||||
|
|
||||||
services.ResponseBadRequest400IncorrectLogin(w)
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func LogoutFromOMC(w http.ResponseWriter, r *http.Request) {
|
func LogoutFromOMC(w http.ResponseWriter, r *http.Request) {
|
||||||
log.Debug("LogoutFromOMC processing... ")
|
|
||||||
|
|
||||||
// check media type(content type) only support "application/json"
|
// check media type(content type) only support "application/json"
|
||||||
if !IsVallidContentType(r) {
|
if !IsVallidContentType(r) {
|
||||||
@@ -202,14 +183,14 @@ func LogoutFromOMC(w http.ResponseWriter, r *http.Request) {
|
|||||||
// error processing ...
|
// error processing ...
|
||||||
// 401-1 response
|
// 401-1 response
|
||||||
token, ret := globalSession.IsCarriedToken(r)
|
token, ret := globalSession.IsCarriedToken(r)
|
||||||
if ret == false {
|
if ret {
|
||||||
log.Debug("AccessToken is not carried")
|
log.Debug("AccessToken is not carried")
|
||||||
services.ResponseUnauthorized401AccessTokenNotCarried(w)
|
services.ResponseUnauthorized401AccessTokenNotCarried(w)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 401-2 response
|
// 401-2 response
|
||||||
if globalSession.IsValidToken(token) == false {
|
if globalSession.IsValidToken(token) {
|
||||||
log.Debug("AccessToken fails or does not exist")
|
log.Debug("AccessToken fails or does not exist")
|
||||||
services.ResponseUnauthorized401AccessTokenNotExist(w)
|
services.ResponseUnauthorized401AccessTokenNotExist(w)
|
||||||
return
|
return
|
||||||
@@ -217,7 +198,6 @@ func LogoutFromOMC(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
globalSession.EndSession(w, r)
|
globalSession.EndSession(w, r)
|
||||||
services.ResponseStatusOK200Null(w)
|
services.ResponseStatusOK200Null(w)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func HandshakeFromOMC(w http.ResponseWriter, r *http.Request) {
|
func HandshakeFromOMC(w http.ResponseWriter, r *http.Request) {
|
||||||
@@ -240,7 +220,7 @@ func HandshakeFromOMC(w http.ResponseWriter, r *http.Request) {
|
|||||||
// error processing ...
|
// error processing ...
|
||||||
// 401-1 response
|
// 401-1 response
|
||||||
token, ret := globalSession.IsCarriedToken(r)
|
token, ret := globalSession.IsCarriedToken(r)
|
||||||
if ret == false {
|
if !ret {
|
||||||
log.Debug("AccessToken is not carried")
|
log.Debug("AccessToken is not carried")
|
||||||
services.ResponseUnauthorized401AccessTokenNotCarried(w)
|
services.ResponseUnauthorized401AccessTokenNotCarried(w)
|
||||||
return
|
return
|
||||||
@@ -255,7 +235,6 @@ func HandshakeFromOMC(w http.ResponseWriter, r *http.Request) {
|
|||||||
|
|
||||||
// 200 response
|
// 200 response
|
||||||
services.ResponseStatusOK200Null(w)
|
services.ResponseStatusOK200Null(w)
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -363,14 +342,14 @@ func GetNRMByUri(w http.ResponseWriter, r *http.Request) {
|
|||||||
// error processing ...
|
// error processing ...
|
||||||
// 401-1 response
|
// 401-1 response
|
||||||
token, ret := globalSession.IsCarriedToken(r)
|
token, ret := globalSession.IsCarriedToken(r)
|
||||||
if ret == false {
|
if !ret {
|
||||||
log.Debug("AccessToken is not carried")
|
log.Debug("AccessToken is not carried")
|
||||||
services.ResponseUnauthorized401AccessTokenNotCarried(w)
|
services.ResponseUnauthorized401AccessTokenNotCarried(w)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 401-2 response
|
// 401-2 response
|
||||||
if globalSession.IsValidToken(token) == false {
|
if globalSession.IsValidToken(token) {
|
||||||
log.Debug("AccessToken fails or does not exist")
|
log.Debug("AccessToken fails or does not exist")
|
||||||
services.ResponseUnauthorized401AccessTokenNotExist(w)
|
services.ResponseUnauthorized401AccessTokenNotExist(w)
|
||||||
return
|
return
|
||||||
@@ -379,7 +358,7 @@ func GetNRMByUri(w http.ResponseWriter, r *http.Request) {
|
|||||||
// todo...
|
// todo...
|
||||||
plist := globalSession.GetPermissionFromSession(token)
|
plist := globalSession.GetPermissionFromSession(token)
|
||||||
log.Debug("permission list:", plist)
|
log.Debug("permission list:", plist)
|
||||||
if len(plist) == 0 || plist[0] == false {
|
if len(plist) == 0 || !plist[0] {
|
||||||
log.Debug("User permission deny")
|
log.Debug("User permission deny")
|
||||||
services.ResponseForbidden403NotPermission(w)
|
services.ResponseForbidden403NotPermission(w)
|
||||||
return
|
return
|
||||||
@@ -506,7 +485,7 @@ func GetNRMByUri(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
getResponse := services.DataResponse{nameValues}
|
getResponse := services.DataResponse{Data: nameValues}
|
||||||
services.ResponseWithJson(w, http.StatusOK, getResponse)
|
services.ResponseWithJson(w, http.StatusOK, getResponse)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,10 +6,10 @@ import (
|
|||||||
"os/exec"
|
"os/exec"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"be.ems/lib/config"
|
||||||
"be.ems/lib/global"
|
"be.ems/lib/global"
|
||||||
"be.ems/lib/log"
|
"be.ems/lib/log"
|
||||||
"be.ems/lib/services"
|
"be.ems/lib/services"
|
||||||
"be.ems/restagent/config"
|
|
||||||
|
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
"xorm.io/xorm"
|
"xorm.io/xorm"
|
||||||
|
|||||||
@@ -10,12 +10,12 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"be.ems/lib/config"
|
||||||
"be.ems/lib/core/ctx"
|
"be.ems/lib/core/ctx"
|
||||||
"be.ems/lib/global"
|
"be.ems/lib/global"
|
||||||
"be.ems/lib/log"
|
"be.ems/lib/log"
|
||||||
"be.ems/lib/mmlp"
|
"be.ems/lib/mmlp"
|
||||||
"be.ems/lib/services"
|
"be.ems/lib/services"
|
||||||
"be.ems/restagent/config"
|
|
||||||
tokenConst "be.ems/src/framework/constants/token"
|
tokenConst "be.ems/src/framework/constants/token"
|
||||||
neModel "be.ems/src/modules/network_element/model"
|
neModel "be.ems/src/modules/network_element/model"
|
||||||
neService "be.ems/src/modules/network_element/service"
|
neService "be.ems/src/modules/network_element/service"
|
||||||
|
|||||||
@@ -11,11 +11,11 @@ import (
|
|||||||
|
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
|
|
||||||
|
"be.ems/lib/config"
|
||||||
"be.ems/lib/global"
|
"be.ems/lib/global"
|
||||||
"be.ems/lib/log"
|
"be.ems/lib/log"
|
||||||
"be.ems/lib/oauth"
|
"be.ems/lib/oauth"
|
||||||
"be.ems/lib/services"
|
"be.ems/lib/services"
|
||||||
"be.ems/restagent/config"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type ErrorOAuthResponse struct {
|
type ErrorOAuthResponse struct {
|
||||||
|
|||||||
@@ -9,9 +9,9 @@ import (
|
|||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
g "github.com/gosnmp/gosnmp"
|
g "github.com/gosnmp/gosnmp"
|
||||||
|
|
||||||
|
"be.ems/lib/config"
|
||||||
"be.ems/lib/log"
|
"be.ems/lib/log"
|
||||||
"be.ems/lib/services"
|
"be.ems/lib/services"
|
||||||
"be.ems/restagent/config"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
|
|||||||
@@ -12,12 +12,12 @@ import (
|
|||||||
|
|
||||||
"be.ems/features/pm/kpi_c_report"
|
"be.ems/features/pm/kpi_c_report"
|
||||||
"be.ems/features/pm/kpi_c_title"
|
"be.ems/features/pm/kpi_c_title"
|
||||||
|
"be.ems/lib/config"
|
||||||
"be.ems/lib/dborm"
|
"be.ems/lib/dborm"
|
||||||
evaluate "be.ems/lib/eval"
|
evaluate "be.ems/lib/eval"
|
||||||
"be.ems/lib/global"
|
"be.ems/lib/global"
|
||||||
"be.ems/lib/log"
|
"be.ems/lib/log"
|
||||||
"be.ems/lib/services"
|
"be.ems/lib/services"
|
||||||
"be.ems/restagent/config"
|
|
||||||
|
|
||||||
neService "be.ems/src/modules/network_element/service"
|
neService "be.ems/src/modules/network_element/service"
|
||||||
wsService "be.ems/src/modules/ws/service"
|
wsService "be.ems/src/modules/ws/service"
|
||||||
|
|||||||
@@ -6,12 +6,12 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"be.ems/lib/config"
|
||||||
"be.ems/lib/dborm"
|
"be.ems/lib/dborm"
|
||||||
"be.ems/lib/global"
|
"be.ems/lib/global"
|
||||||
"be.ems/lib/log"
|
"be.ems/lib/log"
|
||||||
"be.ems/lib/oauth"
|
"be.ems/lib/oauth"
|
||||||
"be.ems/lib/services"
|
"be.ems/lib/services"
|
||||||
"be.ems/restagent/config"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@@ -79,14 +79,6 @@ func LoginFromOMC(w http.ResponseWriter, r *http.Request) {
|
|||||||
services.ResponseBadRequest400IncorrectLogin(w)
|
services.ResponseBadRequest400IncorrectLogin(w)
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
validUser, user, err := dborm.XormCheckLoginUser(oAuthBody.UserName,
|
|
||||||
oAuthBody.Value, config.GetYamlConfig().Auth.Crypt)
|
|
||||||
if !validUser || err != nil {
|
|
||||||
// response 400-4
|
|
||||||
log.Error("Authentication failed, mismatch user or password")
|
|
||||||
services.ResponseErrorWithJson(w, 400, err.Error())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
token := oauth.GenRandToken("omc") // Generate new token to session ID
|
token := oauth.GenRandToken("omc") // Generate new token to session ID
|
||||||
sourceAddr := r.RemoteAddr[:strings.Index(r.RemoteAddr, ":")]
|
sourceAddr := r.RemoteAddr[:strings.Index(r.RemoteAddr, ":")]
|
||||||
@@ -103,11 +95,6 @@ func LoginFromOMC(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if user != nil {
|
|
||||||
empty := []string{}
|
|
||||||
services.ResponseStatusOK200LoginWhitRP(w, token, user, empty, empty)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
services.ResponseBadRequest400IncorrectLogin(w)
|
services.ResponseBadRequest400IncorrectLogin(w)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,9 +8,9 @@ import (
|
|||||||
"os/exec"
|
"os/exec"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"be.ems/lib/config"
|
||||||
"be.ems/lib/log"
|
"be.ems/lib/log"
|
||||||
"be.ems/lib/services"
|
"be.ems/lib/services"
|
||||||
"be.ems/restagent/config"
|
|
||||||
_ "github.com/go-sql-driver/mysql"
|
_ "github.com/go-sql-driver/mysql"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -14,11 +14,11 @@ import (
|
|||||||
"github.com/go-resty/resty/v2"
|
"github.com/go-resty/resty/v2"
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
|
|
||||||
|
"be.ems/lib/config"
|
||||||
"be.ems/lib/dborm"
|
"be.ems/lib/dborm"
|
||||||
"be.ems/lib/global"
|
"be.ems/lib/global"
|
||||||
"be.ems/lib/log"
|
"be.ems/lib/log"
|
||||||
"be.ems/lib/services"
|
"be.ems/lib/services"
|
||||||
"be.ems/restagent/config"
|
|
||||||
tokenConst "be.ems/src/framework/constants/token"
|
tokenConst "be.ems/src/framework/constants/token"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -12,12 +12,12 @@ import (
|
|||||||
"github.com/go-resty/resty/v2"
|
"github.com/go-resty/resty/v2"
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
|
|
||||||
|
"be.ems/lib/config"
|
||||||
"be.ems/lib/dborm"
|
"be.ems/lib/dborm"
|
||||||
"be.ems/lib/global"
|
"be.ems/lib/global"
|
||||||
"be.ems/lib/log"
|
"be.ems/lib/log"
|
||||||
"be.ems/lib/run"
|
"be.ems/lib/run"
|
||||||
"be.ems/lib/services"
|
"be.ems/lib/services"
|
||||||
"be.ems/restagent/config"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|||||||
@@ -8,12 +8,12 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"be.ems/lib/config"
|
||||||
"be.ems/lib/core/ctx"
|
"be.ems/lib/core/ctx"
|
||||||
"be.ems/lib/dborm"
|
"be.ems/lib/dborm"
|
||||||
"be.ems/lib/global"
|
"be.ems/lib/global"
|
||||||
"be.ems/lib/log"
|
"be.ems/lib/log"
|
||||||
"be.ems/lib/services"
|
"be.ems/lib/services"
|
||||||
"be.ems/restagent/config"
|
|
||||||
tokenConst "be.ems/src/framework/constants/token"
|
tokenConst "be.ems/src/framework/constants/token"
|
||||||
neService "be.ems/src/modules/network_element/service"
|
neService "be.ems/src/modules/network_element/service"
|
||||||
"github.com/go-resty/resty/v2"
|
"github.com/go-resty/resty/v2"
|
||||||
|
|||||||
@@ -11,8 +11,6 @@ import (
|
|||||||
"be.ems/lib/log"
|
"be.ems/lib/log"
|
||||||
|
|
||||||
"gopkg.in/yaml.v3"
|
"gopkg.in/yaml.v3"
|
||||||
//"github.com/go-yaml-comment/yaml"
|
|
||||||
//"github.com/goccy/go-yaml"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// Yaml struct of config
|
// Yaml struct of config
|
||||||
@@ -11,9 +11,9 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"be.ems/lib/config"
|
||||||
"be.ems/lib/log"
|
"be.ems/lib/log"
|
||||||
"be.ems/lib/oauth"
|
"be.ems/lib/oauth"
|
||||||
"be.ems/restagent/config"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// SessionMgr session manager
|
// SessionMgr session manager
|
||||||
|
|||||||
Reference in New Issue
Block a user