Fine tuning on dispatcher methods

This commit is contained in:
TeoV
2018-06-06 10:20:53 -04:00
committed by Dan Christian Bogos
parent ebc419771d
commit 9ca91cc401
3 changed files with 30 additions and 12 deletions

View File

@@ -49,8 +49,11 @@ func (dS *DispatcherService) ResourceSv1GetResourcesForEvent(args ArgsV1ResUsage
if err = dS.authorizeEvent(ev, &rplyEv); err != nil {
return
}
mp := utils.ParseStringMap(rplyEv.CGREvent.Event[utils.APIMethods].(string))
if !mp.HasKey(utils.ResourceSv1GetResourcesForEvent) {
var apiMethods string
if apiMethods, err = rplyEv.CGREvent.FieldAsString(utils.APIMethods); err != nil {
return
}
if !utils.ParseStringMap(apiMethods).HasKey(utils.ResourceSv1GetResourcesForEvent) {
return utils.ErrUnauthorizedApi
}
return dS.resS.Call(utils.ResourceSv1GetResourcesForEvent, args.ArgRSv1ResourceUsage, reply)

View File

@@ -52,8 +52,11 @@ func (dS *DispatcherService) StatSv1GetStatQueuesForEvent(args *CGREvWithApiKey,
if err = dS.authorizeEvent(ev, &rplyEv); err != nil {
return
}
mp := utils.ParseStringMap(rplyEv.CGREvent.Event[utils.APIMethods].(string))
if !mp.HasKey(utils.StatSv1GetStatQueuesForEvent) {
var apiMethods string
if apiMethods, err = rplyEv.CGREvent.FieldAsString(utils.APIMethods); err != nil {
return
}
if !utils.ParseStringMap(apiMethods).HasKey(utils.StatSv1GetStatQueuesForEvent) {
return utils.ErrUnauthorizedApi
}
return dS.statS.Call(utils.StatSv1GetStatQueuesForEvent, args.CGREvent, reply)
@@ -76,8 +79,11 @@ func (dS *DispatcherService) StatSv1GetQueueStringMetrics(args *TntIDWithApiKey,
if err = dS.authorizeEvent(ev, &rplyEv); err != nil {
return
}
mp := utils.ParseStringMap(rplyEv.CGREvent.Event[utils.APIMethods].(string))
if !mp.HasKey(utils.StatSv1GetQueueStringMetrics) {
var apiMethods string
if apiMethods, err = rplyEv.CGREvent.FieldAsString(utils.APIMethods); err != nil {
return
}
if !utils.ParseStringMap(apiMethods).HasKey(utils.StatSv1GetQueueStringMetrics) {
return utils.ErrUnauthorizedApi
}
return dS.statS.Call(utils.StatSv1GetQueueStringMetrics, args.TenantID, reply)
@@ -100,8 +106,11 @@ func (dS *DispatcherService) StatSv1ProcessEvent(args *CGREvWithApiKey,
if err = dS.authorizeEvent(ev, &rplyEv); err != nil {
return
}
mp := utils.ParseStringMap(rplyEv.CGREvent.Event[utils.APIMethods].(string))
if !mp.HasKey(utils.StatSv1ProcessEvent) {
var apiMethods string
if apiMethods, err = rplyEv.CGREvent.FieldAsString(utils.APIMethods); err != nil {
return
}
if !utils.ParseStringMap(apiMethods).HasKey(utils.StatSv1ProcessEvent) {
return utils.ErrUnauthorizedApi
}
return dS.statS.Call(utils.StatSv1ProcessEvent, args.CGREvent, reply)

View File

@@ -82,8 +82,11 @@ func (dS *DispatcherService) ThresholdSv1GetThresholdForEvent(args *ArgsProcessE
if err = dS.authorizeEvent(ev, &rplyEv); err != nil {
return
}
mp := utils.ParseStringMap(rplyEv.CGREvent.Event[utils.APIMethods].(string))
if !mp.HasKey(utils.ThresholdSv1GetThresholdsForEvent) {
var apiMethods string
if apiMethods, err = rplyEv.CGREvent.FieldAsString(utils.APIMethods); err != nil {
return
}
if !utils.ParseStringMap(apiMethods).HasKey(utils.ThresholdSv1GetThresholdsForEvent) {
return utils.ErrUnauthorizedApi
}
return dS.thdS.Call(utils.ThresholdSv1GetThresholdsForEvent, args.TenantID, t)
@@ -106,8 +109,11 @@ func (dS *DispatcherService) ThresholdSv1ProcessEvent(args *ArgsProcessEventWith
if err = dS.authorizeEvent(ev, &rplyEv); err != nil {
return
}
mp := utils.ParseStringMap(rplyEv.CGREvent.Event[utils.APIMethods].(string))
if !mp.HasKey(utils.ThresholdSv1ProcessEvent) {
var apiMethods string
if apiMethods, err = rplyEv.CGREvent.FieldAsString(utils.APIMethods); err != nil {
return
}
if !utils.ParseStringMap(apiMethods).HasKey(utils.ThresholdSv1ProcessEvent) {
return utils.ErrUnauthorizedApi
}
return dS.thdS.Call(utils.ThresholdSv1ProcessEvent, args.ArgsProcessEvent, tIDs)