Rights Behaviors
This commit is contained in:
@@ -187,8 +187,9 @@ func VerifyAuthAction[T ResourceInstanceITF](baseInstance []T, request *tools.AP
|
||||
if request == nil {
|
||||
continue
|
||||
}
|
||||
if grps, ok := peers[request.PeerID]; ok || config.GetConfig().Whitelist {
|
||||
if (ok && slices.Contains(grps, "*")) || (!ok && config.GetConfig().Whitelist) {
|
||||
_, allOK := peers["*"]
|
||||
if grps, ok := peers[request.PeerID]; ok || allOK || config.GetConfig().Whitelist {
|
||||
if allOK || (ok && slices.Contains(grps, "*")) || (!ok && config.GetConfig().Whitelist) {
|
||||
instance.FilterInstance(request.PeerID)
|
||||
instances = append(instances, instance)
|
||||
// TODO filter Partners + Profiles...
|
||||
@@ -257,7 +258,7 @@ func (ri *ResourceInstance[T]) IsPeerless() bool {
|
||||
func (ri *ResourceInstance[T]) FilterInstance(peerID string) {
|
||||
partnerships := []T{}
|
||||
for _, p := range ri.Partnerships {
|
||||
if p.GetPeerGroups()[peerID] != nil {
|
||||
if p.GetPeerGroups()["*"] != nil || p.GetPeerGroups()[peerID] != nil {
|
||||
p.FilterPartnership(peerID)
|
||||
partnerships = append(partnerships, p)
|
||||
}
|
||||
@@ -358,11 +359,15 @@ type ResourcePartnerShip[T pricing.PricingProfileITF] struct {
|
||||
}
|
||||
|
||||
func (ri *ResourcePartnerShip[T]) FilterPartnership(peerID string) {
|
||||
if ri.PeerGroups[peerID] == nil {
|
||||
if ri.PeerGroups["*"] == nil && ri.PeerGroups[peerID] == nil {
|
||||
ri.PeerGroups = map[string][]string{}
|
||||
} else {
|
||||
ri.PeerGroups = map[string][]string{
|
||||
peerID: ri.PeerGroups[peerID],
|
||||
ri.PeerGroups = map[string][]string{}
|
||||
if ri.PeerGroups["*"] != nil {
|
||||
ri.PeerGroups["*"] = ri.PeerGroups["*"]
|
||||
}
|
||||
if ri.PeerGroups[peerID] != nil {
|
||||
ri.PeerGroups[peerID] = ri.PeerGroups[peerID]
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -388,7 +393,15 @@ Une bill (facture) représente alors... l'emission d'une facture à un instant T
|
||||
*/
|
||||
func (ri *ResourcePartnerShip[T]) GetPricingsProfiles(peerID string, groups []string) []pricing.PricingProfileITF {
|
||||
profiles := []pricing.PricingProfileITF{}
|
||||
if ri.PeerGroups[peerID] == nil {
|
||||
if ri.PeerGroups["*"] == nil && ri.PeerGroups[peerID] == nil {
|
||||
return profiles
|
||||
}
|
||||
if ri.PeerGroups["*"] != nil {
|
||||
for _, ri := range ri.PricingProfiles {
|
||||
for _, i := range ri {
|
||||
profiles = append(profiles, i)
|
||||
}
|
||||
}
|
||||
return profiles
|
||||
}
|
||||
for _, p := range ri.PeerGroups[peerID] {
|
||||
@@ -420,6 +433,7 @@ func (rp *ResourcePartnerShip[T]) GetPeerGroups() map[string][]string {
|
||||
return rp.PeerGroups
|
||||
}
|
||||
return map[string][]string{
|
||||
"*": {"*"},
|
||||
pp.GetID(): {"*"},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user