feat: user roles (#852)

* [WIP] feat: user roles

* update

* update

* admin handler

* update

* feat: user-specific connection secret

* simplify some logics

* cleanup

* update waf

* update user api error handling

* update waf api

* fix codeql

* update waf table

* fix several problems

* add pagination for waf api

* update permission checks

* switch to runtime check

* 1

* cover?

* some changes
This commit is contained in:
UUBulb
2024-12-22 00:05:41 +08:00
committed by GitHub
parent 50ee62172f
commit 653d0cf2e9
35 changed files with 841 additions and 180 deletions

View File

@@ -11,6 +11,7 @@ import (
"github.com/jinzhu/copier"
"github.com/nezhahq/nezha/model"
"github.com/nezhahq/nezha/pkg/utils"
pb "github.com/nezhahq/nezha/proto"
)
@@ -174,11 +175,7 @@ func (ss *ServiceSentinel) UpdateServiceList() {
ss.ServiceListLock.Lock()
defer ss.ServiceListLock.Unlock()
ss.ServiceList = make([]*model.Service, 0, len(ss.Services))
for _, v := range ss.Services {
ss.ServiceList = append(ss.ServiceList, v)
}
ss.ServiceList = utils.MapValuesToSlice(ss.Services)
slices.SortFunc(ss.ServiceList, func(a, b *model.Service) int {
return cmp.Compare(a.ID, b.ID)
})
@@ -192,13 +189,6 @@ func (ss *ServiceSentinel) loadServiceHistory() {
panic(err)
}
ss.serviceResponseDataStoreLock.Lock()
defer ss.serviceResponseDataStoreLock.Unlock()
ss.monthlyStatusLock.Lock()
defer ss.monthlyStatusLock.Unlock()
ss.ServicesLock.Lock()
defer ss.ServicesLock.Unlock()
for i := 0; i < len(services); i++ {
task := *services[i]
// 通过cron定时将服务监控任务传递给任务调度管道