light modification

This commit is contained in:
mr 2025-01-22 11:16:35 +01:00
parent 287aa3dea3
commit 2a93b17d71

View File

@ -1,6 +1,7 @@
package resources package resources
import ( import (
"fmt"
"slices" "slices"
"cloud.o-forge.io/core/oc-lib/config" "cloud.o-forge.io/core/oc-lib/config"
@ -100,15 +101,20 @@ func (abs *AbstractIntanciatedResource[T]) VerifyAuth(request *tools.APIRequest)
func verifyAuthAction[T ResourceInstanceITF](baseInstance []T, request *tools.APIRequest) []T { func verifyAuthAction[T ResourceInstanceITF](baseInstance []T, request *tools.APIRequest) []T {
instances := []T{} instances := []T{}
fmt.Println("baseInstance", baseInstance)
for _, instance := range baseInstance { for _, instance := range baseInstance {
_, peerGroups := instance.GetPeerGroups() _, peerGroups := instance.GetPeerGroups()
fmt.Println("peerGroups", peerGroups, request)
for _, peers := range peerGroups { for _, peers := range peerGroups {
if request == nil { if request == nil {
continue continue
} }
fmt.Println("request.PeerID]", peers[request.PeerID])
if grps, ok := peers[request.PeerID]; ok || config.GetConfig().Whitelist { if grps, ok := peers[request.PeerID]; ok || config.GetConfig().Whitelist {
fmt.Println("grps", grps, request.Groups)
if (ok && slices.Contains(grps, "*")) || (!ok && config.GetConfig().Whitelist) { if (ok && slices.Contains(grps, "*")) || (!ok && config.GetConfig().Whitelist) {
instances = append(instances, instance) instances = append(instances, instance)
continue
} }
for _, grp := range grps { for _, grp := range grps {
if slices.Contains(request.Groups, grp) { if slices.Contains(request.Groups, grp) {