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