func (m *Module) IsFuncCallAuthorised(ctx context.Context, project, service, function, token string, params interface{}) (*model.PostProcess, model.RequestParams, error) {
	m.RLock()
	defer m.RUnlock()
	rule, err := m.getFunctionRule(ctx, project, service, function)
	if err != nil {
		return nil, model.RequestParams{}, err
	}
	if m.project != project {
		return nil, model.RequestParams{}, errors.New("invalid project details provided")
	}
	var auth map[string]interface{}
	if rule.Rule != "allow" {
		auth, err = m.jwt.ParseToken(ctx, token)
		if err != nil {
			return nil, model.RequestParams{}, err
		}
	}
	if auth != nil {
		if id, p := auth["id"]; p && id == utils.InternalUserID {
			hookResponse := m.integrationMan.InvokeHook(ctx, model.RequestParams{
				Claims:     auth,
				Resource:   "internal-api-access",
				Op:         "service-call",
				Attributes: map[string]string{"project": project},
			})
			if hookResponse.CheckResponse() {
				attr := map[string]string{"project": project, "service": service, "endpoint": function}
				return nil, model.RequestParams{Resource: "service-call", Op: "access", Claims: auth, Attributes: attr}, hookResponse.Error()
			}
		}
	}
	actions, err := m.matchRule(ctx, project, rule, map[string]interface{}{
		"args": map[string]interface{}{"auth": auth, "params": params, "token": token},
	}, auth, model.ReturnWhereStub{})
	if err != nil {
		return nil, model.RequestParams{}, err
	}
	attr := map[string]string{"project": project, "service": service, "endpoint": function}
	reqParams := model.RequestParams{Resource: "service-call", Op: "access", Claims: auth, Attributes: attr}
	return actions, reqParams, nil
}
IsFuncCallAuthorised checks if the func call is authorised
package auth
import (
	"context"
	"errors"
	"fmt"
	"github.com/spaceuptech/helpers"
	"github.com/spaceuptech/space-cloud/gateway/config"
	"github.com/spaceuptech/space-cloud/gateway/model"
	"github.com/spaceuptech/space-cloud/gateway/utils"
)