mirror of
https://github.com/TeaOSLab/EdgeAdmin.git
synced 2025-12-25 03:26:34 +08:00
优化路由规则中访问控制功能
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/rpc/pb"
|
||||
"github.com/TeaOSLab/EdgeCommon/pkg/serverconfigs"
|
||||
"github.com/iwind/TeaGo/actions"
|
||||
"github.com/iwind/TeaGo/lists"
|
||||
)
|
||||
|
||||
type IndexAction struct {
|
||||
@@ -28,6 +29,28 @@ func (this *IndexAction) RunGet(params struct {
|
||||
}
|
||||
|
||||
this.Data["webId"] = webConfig.Id
|
||||
|
||||
// 移除不存在的鉴权方法
|
||||
var allTypes = []string{}
|
||||
for _, def := range serverconfigs.FindAllHTTPAuthTypes() {
|
||||
allTypes = append(allTypes, def.Code)
|
||||
}
|
||||
|
||||
if webConfig.Auth != nil {
|
||||
var refs = webConfig.Auth.PolicyRefs
|
||||
var realRefs = []*serverconfigs.HTTPAuthPolicyRef{}
|
||||
for _, ref := range refs {
|
||||
if ref.AuthPolicy == nil {
|
||||
continue
|
||||
}
|
||||
if !lists.ContainsString(allTypes, ref.AuthPolicy.Type) {
|
||||
continue
|
||||
}
|
||||
realRefs = append(realRefs, ref)
|
||||
}
|
||||
webConfig.Auth.PolicyRefs = realRefs
|
||||
}
|
||||
|
||||
this.Data["authConfig"] = webConfig.Auth
|
||||
|
||||
this.Show()
|
||||
|
||||
Reference in New Issue
Block a user