diff --git a/agent/router/entry_xpackee.go b/agent/router/entry_xpackee.go new file mode 100644 index 000000000..f76560a2d --- /dev/null +++ b/agent/router/entry_xpackee.go @@ -0,0 +1,19 @@ +//go:build xpackee + +package router + +import ( + xpackRouter "github.com/1Panel-dev/1Panel/agent/xpack/router" +) + +func RouterGroups() []CommonRouter { + baseRouter := commonGroups() + for _, ro := range xpackRouter.XpackGroups() { + if val, ok := ro.(CommonRouter); ok { + baseRouter = append(baseRouter, val) + } + } + return baseRouter +} + +var RouterGroupApp = RouterGroups() diff --git a/agent/server/init_xpackee.go b/agent/server/init_xpackee.go new file mode 100644 index 000000000..411aaf8f1 --- /dev/null +++ b/agent/server/init_xpackee.go @@ -0,0 +1,11 @@ +//go:build xpackee + +package server + +import ( + xpack "github.com/1Panel-dev/1Panel/agent/xpack" +) + +func InitOthers() { + xpack.Init() +} diff --git a/agent/utils/xpack/xpackee.go b/agent/utils/xpack/xpackee.go new file mode 100644 index 000000000..69df0ddbd --- /dev/null +++ b/agent/utils/xpack/xpackee.go @@ -0,0 +1,74 @@ +//go:build xpackee + +package xpack + +import ( + "net/http" + + "github.com/1Panel-dev/1Panel/agent/app/dto" + "github.com/1Panel-dev/1Panel/agent/app/model" + edition "github.com/1Panel-dev/1Panel/agent/xpack/edition" + "github.com/gin-gonic/gin" +) + +func RemoveTamper(website string) { + edition.RemoveTamper(website) +} + +func StartClam(startClam *model.Clam, isUpdate bool) (int, error) { + return edition.StartClam(startClam, isUpdate) +} + +func LoadNodeInfo(isBase bool) (model.NodeInfo, error) { + return edition.LoadNodeInfo(isBase) +} + +func GetImagePrefix() string { + return edition.GetImagePrefix() +} + +func IsUseCustomApp() bool { + return edition.IsUseCustomApp() +} + +func IsXpack() bool { + return edition.IsXpack() +} + +func CreateTaskScanSMSAlertLog(info dto.AlertDTO, alertType string, create dto.AlertLogCreate, pushAlert dto.PushAlert, method string) error { + return edition.CreateTaskScanSMSAlertLog(info, alertType, create, pushAlert, method) +} + +func CreateSMSAlertLog(alertType string, info dto.AlertDTO, create dto.AlertLogCreate, project string, params []dto.Param, method string) error { + return edition.CreateSMSAlertLog(alertType, info, create, project, params, method) +} + +func CreateTaskScanWebhookAlertLog(alert dto.AlertDTO, alertType string, create dto.AlertLogCreate, pushAlert dto.PushAlert, method string, transport *http.Transport, agentInfo *dto.AgentInfo) error { + return edition.CreateTaskScanWebhookAlertLog(alert, alertType, create, pushAlert, method, transport, agentInfo) +} + +func CreateWebhookAlertLog(alertType string, info dto.AlertDTO, create dto.AlertLogCreate, project string, params []dto.Param, method string, transport *http.Transport, agentInfo *dto.AgentInfo) error { + return edition.CreateWebhookAlertLog(alertType, info, create, project, params, method, transport, agentInfo) +} + +func GetLicenseErrorAlert() (uint, error) { + return edition.GetLicenseErrorAlert() +} + +func GetNodeErrorAlert() (uint, error) { + return edition.GetNodeErrorAlert() +} + +func LoadRequestTransport() *http.Transport { return edition.LoadRequestTransport() } + +func ValidateCertificate(c *gin.Context) bool { + return edition.ValidateCertificate(c) +} + +func PushSSLToNode(websiteSSL *model.WebsiteSSL) error { + return edition.PushSSLToNode(websiteSSL) +} + +func GetAgentInfo() (*dto.AgentInfo, error) { + return edition.GetAgentInfo() +} diff --git a/core/app/api/v2/helper/helper.go b/core/app/api/v2/helper/helper.go index cd555906e..4f7d10e2b 100644 --- a/core/app/api/v2/helper/helper.go +++ b/core/app/api/v2/helper/helper.go @@ -22,6 +22,15 @@ func ErrorWithDetail(ctx *gin.Context, code int, msgKey string, err error) { res.Code = 401 res.Message = msgKey } + if msgKey == "ErrRBAC" { + res.Code = 412 + if err != nil { + res.Message = err.Error() + ctx.JSON(http.StatusOK, res) + ctx.Abort() + return + } + } res.Message = i18n.GetMsgWithMap(msgKey, map[string]interface{}{"detail": err}) ctx.JSON(http.StatusOK, res) ctx.Abort() diff --git a/core/app/api/v2/setting.go b/core/app/api/v2/setting.go index 102f11b07..11b40d242 100644 --- a/core/app/api/v2/setting.go +++ b/core/app/api/v2/setting.go @@ -109,7 +109,7 @@ func (b *BaseApi) UpdateSetting(c *gin.Context) { req.Value = value } - if err := settingService.Update(req.Key, req.Value); err != nil { + if err := settingService.Update(c, req.Key, req.Value); err != nil { helper.InternalServer(c, err) return } @@ -187,7 +187,7 @@ func (b *BaseApi) UpdateMenu(c *gin.Context) { return } - if err := settingService.Update(req.Key, req.Value); err != nil { + if err := settingService.Update(c, req.Key, req.Value); err != nil { helper.InternalServer(c, err) return } @@ -411,17 +411,17 @@ func (b *BaseApi) MFABind(c *gin.Context) { return } - if err := settingService.Update("MFAInterval", req.Interval); err != nil { + if err := settingService.Update(c, "MFAInterval", req.Interval); err != nil { helper.InternalServer(c, err) return } - if err := settingService.Update("MFAStatus", constant.StatusEnable); err != nil { + if err := settingService.Update(c, "MFAStatus", constant.StatusEnable); err != nil { helper.InternalServer(c, err) return } - if err := settingService.Update("MFASecret", req.Secret); err != nil { + if err := settingService.Update(c, "MFASecret", req.Secret); err != nil { helper.InternalServer(c, err) return } diff --git a/core/app/service/auth.go b/core/app/service/auth.go index 70e059b8c..55a1491b0 100644 --- a/core/app/service/auth.go +++ b/core/app/service/auth.go @@ -142,7 +142,7 @@ func (u *AuthService) generateSession(c *gin.Context, name string) (*dto.UserLog return nil, err } - sessionUser := psession.SessionUser{Name: name, Role: "ADMIN"} + sessionUser := psession.SessionUser{ID: psession.SuperAdminSessionUserID, Name: name, Role: "ADMIN"} lifeTime = xpack.LoadSessionTimeout(sessionUser, lifeTime) if err := global.SESSION.SetFresh(c, sessionUser, httpsSetting.Value == constant.StatusEnable, lifeTime); err != nil { return nil, err diff --git a/core/app/service/setting.go b/core/app/service/setting.go index 8c958f897..f01cd3ece 100644 --- a/core/app/service/setting.go +++ b/core/app/service/setting.go @@ -44,7 +44,7 @@ type SettingService struct{} type ISettingService interface { GetSettingInfo() (*dto.SettingInfo, error) LoadInterfaceAddr() ([]string, error) - Update(key, value string) error + Update(c *gin.Context, key, value string) error UpdatePassword(c *gin.Context, old, new string) error UpdatePort(port uint) error UpdateBindInfo(req dto.BindInfo) error @@ -127,7 +127,7 @@ func sortShowMenus(menus []dto.ShowMenu) { }) } -func (u *SettingService) Update(key, value string) error { +func (u *SettingService) Update(c *gin.Context, key, value string) error { oldVal, err := settingRepo.Get(repo.WithByKey(key)) if err != nil { return err @@ -180,7 +180,7 @@ func (u *SettingService) Update(key, value string) error { return err } case "UserName", "Password": - _ = global.SESSION.DeleteByID("") + u.deleteCurrentSession(c) case "Language": i18n.SetCachedDBLanguage(value) if err := xpack.Sync(constant.SyncLanguage); err != nil { @@ -566,10 +566,21 @@ func (u *SettingService) UpdatePassword(c *gin.Context, old, new string) error { if err := u.HandlePasswordExpired(c, old, new); err != nil { return err } - _ = global.SESSION.DeleteByID("") + u.deleteCurrentSession(c) return nil } +func (u *SettingService) deleteCurrentSession(c *gin.Context) { + if c == nil { + return + } + sessionUser, err := global.SESSION.Get(c) + if err != nil || sessionUser.ID == "" { + return + } + _ = global.SESSION.DeleteByID(sessionUser.ID) +} + func (u *SettingService) clearPasskeySettings() error { if err := settingRepo.Update(passkey.PasskeyUserIDSettingKey, ""); err != nil { return err diff --git a/core/cmd/server/validator_linux_amd64 b/core/cmd/server/validator_linux_amd64 new file mode 100644 index 000000000..3e2a15dfb Binary files /dev/null and b/core/cmd/server/validator_linux_amd64 differ diff --git a/core/i18n/lang/en.yaml b/core/i18n/lang/en.yaml index e6025e67e..e710652be 100644 --- a/core/i18n/lang/en.yaml +++ b/core/i18n/lang/en.yaml @@ -55,6 +55,8 @@ AppInstallCheck: 'Check application installation environment' # backup ErrBackupInUsed: "This backup account is used in scheduled tasks and cannot be deleted" +ErrRolePresetCannotDelete: "System preset roles cannot be deleted" +ErrRoleBoundToUser: "This role is already bound to users and cannot be deleted" ErrBackupCheck: "Backup account connection test failed {{ .err }}" ErrBackupLocal: "Local server backup account does not support this operation!" ErrBackupPublic: "Detected that this backup account is not public, check and try again!" diff --git a/core/i18n/lang/es-ES.yaml b/core/i18n/lang/es-ES.yaml index 0e93cee33..6ae891e5b 100644 --- a/core/i18n/lang/es-ES.yaml +++ b/core/i18n/lang/es-ES.yaml @@ -54,6 +54,8 @@ AppInstallCheck: 'Verificar entorno de instalación de aplicación' # backup ErrBackupInUsed: 'Cuenta de respaldo en uso por tarea programada' +ErrRolePresetCannotDelete: "System preset roles cannot be deleted" +ErrRoleBoundToUser: "This role is already bound to users and cannot be deleted" ErrBackupCheck: 'Conexión de respaldo falló: {{ .err }}' ErrBackupLocal: "La cuenta de respaldo del servidor local no admite esta operación" ErrBackupPublic: "Se detectó que esta cuenta de respaldo no es pública, verifique e intente de nuevo" diff --git a/core/i18n/lang/ja.yaml b/core/i18n/lang/ja.yaml index 14278fcda..5eae9cc01 100644 --- a/core/i18n/lang/ja.yaml +++ b/core/i18n/lang/ja.yaml @@ -49,6 +49,8 @@ AppInstallCheck: 'アプリケーションインストール環境を確認' # backup ErrBackupInUsed: 'バックアップアカウントがスケジュールで使用中' +ErrRolePresetCannotDelete: "System preset roles cannot be deleted" +ErrRoleBoundToUser: "This role is already bound to users and cannot be deleted" ErrBackupCheck: '接続テストに失敗しました: {{ .err }}' ErrBackupLocal: "ローカルサーバーバックアップアカウントはこの操作をサポートしていません!" ErrBackupPublic: "このバックアップアカウントが公開されていないと検出されました。再確認してください!" diff --git a/core/i18n/lang/ko.yaml b/core/i18n/lang/ko.yaml index 4fa2c8b35..d83e91c73 100644 --- a/core/i18n/lang/ko.yaml +++ b/core/i18n/lang/ko.yaml @@ -49,6 +49,8 @@ AppInstallCheck: '애플리케이션 설치 환경 확인' # backup ErrBackupInUsed: '백업 계정이 예약에 사용 중' +ErrRolePresetCannotDelete: "System preset roles cannot be deleted" +ErrRoleBoundToUser: "This role is already bound to users and cannot be deleted" ErrBackupCheck: '연결 테스트 실패: {{ .err }}' ErrBackupLocal: "로컬 서버 백업 계정은 이 작업을 지원하지 않습니다" ErrBackupPublic: "이 백업 계정이 공개된 것으로 감지되지 않았습니다. 다시 확인하십시오" diff --git a/core/i18n/lang/ms.yaml b/core/i18n/lang/ms.yaml index b513bebac..2d2962f81 100644 --- a/core/i18n/lang/ms.yaml +++ b/core/i18n/lang/ms.yaml @@ -44,6 +44,8 @@ ErrFileNotFound: "Fail {{ .name }} tidak wujud" # backup ErrBackupInUsed: 'Akaun sandaran sedang digunakan oleh tugas' +ErrRolePresetCannotDelete: "System preset roles cannot be deleted" +ErrRoleBoundToUser: "This role is already bound to users and cannot be deleted" ErrBackupCheck: 'Ujian sambungan gagal: {{ .err }}' ErrBackupLocal: "Akaun sandaran pelayan tempatan tidak menyokong operasi ini" ErrBackupPublic: "Akaun sandaran ini dikesan tidak awam, sila semak semula dan cuba lagi" diff --git a/core/i18n/lang/pt-BR.yaml b/core/i18n/lang/pt-BR.yaml index 46f5586fc..3a8ae4849 100644 --- a/core/i18n/lang/pt-BR.yaml +++ b/core/i18n/lang/pt-BR.yaml @@ -49,6 +49,8 @@ AppInstallCheck: 'Verificar ambiente de instalação da aplicação' # backup ErrBackupInUsed: 'Conta de backup em uso por tarefa' +ErrRolePresetCannotDelete: "System preset roles cannot be deleted" +ErrRoleBoundToUser: "This role is already bound to users and cannot be deleted" ErrBackupCheck: 'Teste de conexão falhou: {{ .err }}' ErrBackupLocal: "A conta de backup do servidor local não suporta essa operação" ErrBackupPublic: "A conta de backup detectada não é pública, por favor verifique e tente novamente" diff --git a/core/i18n/lang/ru.yaml b/core/i18n/lang/ru.yaml index ea5afa56c..d42547908 100644 --- a/core/i18n/lang/ru.yaml +++ b/core/i18n/lang/ru.yaml @@ -49,6 +49,8 @@ AppInstallCheck: 'Проверить среду установки прилож # backup ErrBackupInUsed: 'Аккаунт бэкапа занят задачей' +ErrRolePresetCannotDelete: "System preset roles cannot be deleted" +ErrRoleBoundToUser: "This role is already bound to users and cannot be deleted" ErrBackupCheck: 'Проверка подключения не удалась: {{ .err }}' ErrBackupLocal: "Локальная учетная запись резервного копирования не поддерживает эту операцию" ErrBackupPublic: "Обнаружено, что эта учетная запись резервного копирования не является публичной, проверьте и повторите попытку" diff --git a/core/i18n/lang/tr.yaml b/core/i18n/lang/tr.yaml index a079434e4..edcc6c608 100644 --- a/core/i18n/lang/tr.yaml +++ b/core/i18n/lang/tr.yaml @@ -49,6 +49,8 @@ AppInstallCheck: 'Uygulama kurulum ortamını kontrol et' # backup ErrBackupInUsed: 'Yedek hesabı görevde kullanılıyor' +ErrRolePresetCannotDelete: "System preset roles cannot be deleted" +ErrRoleBoundToUser: "This role is already bound to users and cannot be deleted" ErrBackupCheck: 'Bağlantı testi başarısız: {{ .err }}' ErrBackupLocal: "Yerel sunucu yedekleme hesabı bu işlemi desteklemiyor" ErrBackupPublic: "Bu yedekleme hesabının herkese açık olmadığı tespit edildi, lütfen kontrol edip tekrar deneyin" diff --git a/core/i18n/lang/zh-Hant.yaml b/core/i18n/lang/zh-Hant.yaml index b9c5a70b5..7fc728fa1 100644 --- a/core/i18n/lang/zh-Hant.yaml +++ b/core/i18n/lang/zh-Hant.yaml @@ -49,6 +49,8 @@ AppInstallCheck: '檢查應用安裝環境' #backup ErrBackupInUsed: "該備份帳號已在排程任務中使用,無法刪除" +ErrRolePresetCannotDelete: "系統預設角色,無法刪除" +ErrRoleBoundToUser: "角色已被使用者綁定,無法刪除" ErrBackupCheck: "備份帳號測試連線失敗 {{ .err }}" ErrBackupLocal: "本機伺服器備份帳號暫不支援該操作!" ErrBackupPublic: "偵測到該備份帳號為非公用,請檢查後再試。" diff --git a/core/i18n/lang/zh.yaml b/core/i18n/lang/zh.yaml index 3fb7edca5..b388f2c7d 100644 --- a/core/i18n/lang/zh.yaml +++ b/core/i18n/lang/zh.yaml @@ -55,6 +55,8 @@ AppInstallCheck: "检查应用安装环境" #backup ErrBackupInUsed: "该备份账号已在计划任务中使用,无法删除" +ErrRolePresetCannotDelete: "系统预设角色,无法删除" +ErrRoleBoundToUser: "角色已被用户绑定,无法删除" ErrBackupCheck: "备份账号测试连接失败 {{ .err }}" ErrBackupLocal: "本地服务器备份账号暂不支持该操作!" ErrBackupPublic: "检测到该备份账号为非公用,请检查后重试!" diff --git a/core/init/router/proxy.go b/core/init/router/proxy.go index bba96ac75..7ed1214e3 100644 --- a/core/init/router/proxy.go +++ b/core/init/router/proxy.go @@ -6,13 +6,12 @@ import ( "strconv" "strings" - "github.com/1Panel-dev/1Panel/core/init/proxy" - "github.com/1Panel-dev/1Panel/core/app/api/v2/helper" "github.com/1Panel-dev/1Panel/core/app/repo" "github.com/1Panel-dev/1Panel/core/cmd/server/res" "github.com/1Panel-dev/1Panel/core/constant" "github.com/1Panel-dev/1Panel/core/global" + "github.com/1Panel-dev/1Panel/core/init/proxy" "github.com/1Panel-dev/1Panel/core/utils/xpack" "github.com/gin-gonic/gin" ) diff --git a/core/init/router/router.go b/core/init/router/router.go index 6dd5d9742..a5b9e9bda 100644 --- a/core/init/router/router.go +++ b/core/init/router/router.go @@ -16,6 +16,7 @@ import ( "github.com/1Panel-dev/1Panel/core/middleware" rou "github.com/1Panel-dev/1Panel/core/router" "github.com/1Panel-dev/1Panel/core/utils/security" + "github.com/1Panel-dev/1Panel/core/utils/xpack" "github.com/gin-contrib/gzip" "github.com/gin-gonic/gin" ) @@ -87,6 +88,7 @@ func Routers() *gin.Engine { Router.Use(middleware.PasswordExpired()) Router.Use(middleware.ApiAuth()) Router.Use(middleware.CSRFTokenGuard()) + Router.Use(xpack.CoreRBACMiddlewares()...) Router.Use(Proxy()) PrivateGroup := Router.Group("/api/v2/core") diff --git a/core/init/session/psession/psession.go b/core/init/session/psession/psession.go index 6a290d912..6cee79238 100644 --- a/core/init/session/psession/psession.go +++ b/core/init/session/psession/psession.go @@ -19,6 +19,8 @@ type SessionUser struct { Name string `json:"name"` } +const SuperAdminSessionUserID = "__super_admin__" + type sessionItem struct { CreatedAt time.Time CSRFToken string diff --git a/core/utils/xpack/community.go b/core/utils/xpack/community.go index cc3bda4fc..509e2510e 100644 --- a/core/utils/xpack/community.go +++ b/core/utils/xpack/community.go @@ -10,13 +10,29 @@ import ( "time" baseDto "github.com/1Panel-dev/1Panel/core/app/dto" + "github.com/1Panel-dev/1Panel/core/global" + "github.com/1Panel-dev/1Panel/core/init/proxy" "github.com/1Panel-dev/1Panel/core/init/session/psession" "github.com/1Panel-dev/1Panel/core/utils/ssh" "github.com/1Panel-dev/1Panel/core/xpack/app/model" "github.com/gin-gonic/gin" ) -func Proxy(c *gin.Context, currentNode string) {} +func Proxy(c *gin.Context, currentNode string) { + if currentNode != "local" && currentNode != "" { + c.Next() + return + } + defer func() { + if err := recover(); err != nil && err != http.ErrAbortHandler { + global.LOG.Debug(err) + } + }() + proxy.LocalAgentProxy.ServeHTTP(c.Writer, c.Request) + c.Abort() +} + +func CoreRBACMiddlewares() []gin.HandlerFunc { return nil } func ProxyDocker(proxyURL string) error { return nil } diff --git a/core/utils/xpack/xpack.go b/core/utils/xpack/xpack.go index 007e2889c..6d3319311 100644 --- a/core/utils/xpack/xpack.go +++ b/core/utils/xpack/xpack.go @@ -18,6 +18,8 @@ func Proxy(c *gin.Context, currentNode string) { edition.Proxy(c, currentNode) } +func CoreRBACMiddlewares() []gin.HandlerFunc { return nil } + func ProxyDocker(proxyURL string) error { return edition.ProxyDocker(proxyURL) } func UpdateGroup(name string, group, newGroup uint) error { diff --git a/core/utils/xpack/xpackee.go b/core/utils/xpack/xpackee.go index 7498b001e..c108a1d35 100644 --- a/core/utils/xpack/xpackee.go +++ b/core/utils/xpack/xpackee.go @@ -9,6 +9,7 @@ import ( "github.com/1Panel-dev/1Panel/core/init/session/psession" "github.com/1Panel-dev/1Panel/core/utils/ssh" edition "github.com/1Panel-dev/1Panel/core/xpack-ee/edition" + xeemiddleware "github.com/1Panel-dev/1Panel/core/xpack-ee/router/middleware" "github.com/1Panel-dev/1Panel/core/xpack/app/model" "github.com/gin-gonic/gin" ) @@ -17,6 +18,10 @@ func Proxy(c *gin.Context, currentNode string) { edition.Proxy(c, currentNode) } +func CoreRBACMiddlewares() []gin.HandlerFunc { + return []gin.HandlerFunc{xeemiddleware.RequireRBAC()} +} + func ProxyDocker(proxyURL string) error { return edition.ProxyDocker(proxyURL) } func UpdateGroup(name string, group, newGroup uint) error { diff --git a/frontend/src/api/helper/check-status.ts b/frontend/src/api/helper/check-status.ts index c7a0096be..e61aac37d 100644 --- a/frontend/src/api/helper/check-status.ts +++ b/frontend/src/api/helper/check-status.ts @@ -2,9 +2,9 @@ import i18n from '@/lang'; import router from '@/routers'; import { MsgError } from '@/utils/message'; import { GlobalStore } from '@/store'; -const globalStore = GlobalStore(); export const checkStatus = (status: number, msg: string): void => { + const globalStore = GlobalStore(); switch (status) { case 400: MsgError(msg ? msg : i18n.global.t('commons.res.paramError')); diff --git a/frontend/src/api/index.ts b/frontend/src/api/index.ts index 58b6da3ca..d6d7d3625 100644 --- a/frontend/src/api/index.ts +++ b/frontend/src/api/index.ts @@ -9,7 +9,8 @@ import { encodeBase64 } from '@/utils/base64'; import i18n from '@/lang'; import { changeToLocal } from '@/utils/node'; import { getCookie } from '@/utils/auth'; -const globalStore = GlobalStore(); + +const getGlobalStore = () => GlobalStore(); const config = { baseURL: import.meta.env.VITE_API_URL as string, @@ -28,6 +29,7 @@ class RequestHttp { this.service = axios.create(config); this.service.interceptors.request.use( (config: AxiosRequestConfig) => { + const globalStore = getGlobalStore(); let language = globalStore.language; config.headers = { 'Accept-Language': language, @@ -67,6 +69,7 @@ class RequestHttp { this.service.interceptors.response.use( (response: AxiosResponse) => { + const globalStore = getGlobalStore(); const { data } = response; if (data.code == ResultEnum.OVERDUE || data.code == ResultEnum.FORBIDDEN) { globalStore.isLogin = false; @@ -76,6 +79,10 @@ class RequestHttp { }); return Promise.reject(data); } + if (data.code == ResultEnum.ERRRBAC) { + MsgError(data.message || i18n.global.t('commons.res.forbidden')); + return Promise.reject(data); + } if (data.code == ResultEnum.EXPIRED) { router.push({ name: 'Expired' }); return; diff --git a/frontend/src/api/interface/auth.ts b/frontend/src/api/interface/auth.ts index 95c98e2c7..74d0a6e1b 100644 --- a/frontend/src/api/interface/auth.ts +++ b/frontend/src/api/interface/auth.ts @@ -49,6 +49,9 @@ export namespace Login { id: number; name: string; role: string; + permissions: string[]; + nodeScopes: number[]; + nodeRoles: Array<{ nodeId: number; nodeName: string; roleId: number; roleName: string }>; } export interface AuthInfoUpdate { id: number; diff --git a/frontend/src/api/modules/auth.ts b/frontend/src/api/modules/auth.ts index cb32212a9..33c10bc73 100644 --- a/frontend/src/api/modules/auth.ts +++ b/frontend/src/api/modules/auth.ts @@ -1,6 +1,6 @@ import { Login } from '@/api/interface/auth'; import http from '@/api'; -import { deepCopy } from '@/utils/util'; +import { deepCopy } from '@/utils/misc'; import { Base64 } from 'js-base64'; export const loginApi = (params: Login.ReqLoginForm) => { diff --git a/frontend/src/api/modules/backup.ts b/frontend/src/api/modules/backup.ts index ee2314fe1..4a44c38e5 100644 --- a/frontend/src/api/modules/backup.ts +++ b/frontend/src/api/modules/backup.ts @@ -5,7 +5,7 @@ import { ResPage } from '../interface'; import { Backup } from '../interface/backup'; import { TimeoutEnum } from '@/enums/http-enum'; import { GlobalStore } from '@/store'; -const globalStore = GlobalStore(); +const getGlobalStore = () => GlobalStore(); // backup-agent export const getLocalBackupDir = (node?: string) => { @@ -16,6 +16,7 @@ export const searchBackup = (params: Backup.SearchWithType) => { return http.post>(`/backups/search`, params); }; export const checkBackup = (params: Backup.BackupOperate) => { + const globalStore = getGlobalStore(); let request = deepCopy(params) as Backup.BackupOperate; encodeBase64Fields(request, ['accessKey', 'credential']); if (!params.isPublic || !globalStore.isProductPro) { @@ -24,6 +25,7 @@ export const checkBackup = (params: Backup.BackupOperate) => { return http.post(`/backups/conn/check`, request); }; export const listBucket = (params: Backup.ForBucket) => { + const globalStore = getGlobalStore(); let request = deepCopy(params) as Backup.BackupOperate; encodeBase64Fields(request, ['accessKey', 'credential']); if (!params.isPublic || !globalStore.isProductPro) { diff --git a/frontend/src/components/node-select/index.vue b/frontend/src/components/node-select/index.vue index d891992fe..eb15b0e9d 100644 --- a/frontend/src/components/node-select/index.vue +++ b/frontend/src/components/node-select/index.vue @@ -16,7 +16,6 @@