From 37b3333ae6e3fd17eec9ce1097c80f81c534f291 Mon Sep 17 00:00:00 2001 From: GoEdgeLab Date: Tue, 30 Aug 2022 11:43:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=B7=AF=E7=94=B1=E8=A7=84?= =?UTF-8?q?=E5=88=99=E4=B8=AD=E8=AE=BF=E9=97=AE=E6=8E=A7=E5=88=B6=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/settings/locations/access/index.go | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/internal/web/actions/default/servers/server/settings/locations/access/index.go b/internal/web/actions/default/servers/server/settings/locations/access/index.go index 9bb79f38..2eddf772 100644 --- a/internal/web/actions/default/servers/server/settings/locations/access/index.go +++ b/internal/web/actions/default/servers/server/settings/locations/access/index.go @@ -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()