鉴权调整

This commit is contained in:
momo 2023-11-27 18:23:42 +08:00
parent c1c5bbe0e2
commit cc4a840732

View File

@ -113,7 +113,7 @@ func (l *Ldap) VerifyAuthorityGroup(r *http.Request, options ...LdapOptions) boo
logx.Error("系统出错", err) logx.Error("系统出错", err)
return false return false
} }
getAllApis(metadata, &apiMaps) getAllMetadata(metadata, "api", &apiMaps)
c.Set(groupKey, apiMaps, 5*time.Minute) c.Set(groupKey, apiMaps, 5*time.Minute)
} }
} }
@ -125,14 +125,14 @@ func (l *Ldap) VerifyAuthorityGroup(r *http.Request, options ...LdapOptions) boo
} }
} }
func getAllApis(metadata []*GroupAuthMetadata, apiMaps *map[int64]string) { func getAllMetadata(metadata []*GroupAuthMetadata, dataType string, maps *map[int64]string) {
apiMapsData := *apiMaps apiMapsData := *maps
for _, v := range metadata { for _, v := range metadata {
if v != nil { if v != nil {
if v.Type == "api" { if v.Type == dataType {
apiMapsData[v.Id] = v.Name apiMapsData[v.Id] = v.Name
} else if v.Type == "group" { } else if v.Type == "group" {
getAllApis(v.Metadata, apiMaps) getAllMetadata(v.Metadata, dataType, maps)
} else { } else {
continue continue
} }