func (s *Service) Check(ctx context.Context, credentials *checker.Credentials, account string, operation string) bool {
	log.Trace().Str("account", account).Str("operation", operation).Msg("Checking permissions for operation")
	if credentials == nil {
		log.Error().Str("result", "failed").Msg("No credentials")
		return false
	}
	if credentials.Client == "" {
		log.Warn().Str("result", "denied").Msg("No client name")
		return false
	}
	log := log.With().Str("account", account).Str("operation", operation).Str("client", credentials.Client).Str("account", account).Logger()
	walletName, accountName, err := e2wallet.WalletAndAccountNames(account)
	if err != nil {
		log.Warn().Err(err).Str("result", "denied").Msg("Invalid path")
		return false
	}
	if walletName == "" {
		log.Warn().Err(err).Str("result", "denied").Msg("Missing wallet name")
		return false
	}
	paths, exists := s.access[credentials.Client]
	if !exists {
		log.Warn().Str("result", "denied").Msg("No rules for client")
		return false
	}
	antiOperation := fmt.Sprintf("~%s", operation)
	for _, path := range paths {
		if path.wallet.Match([]byte(walletName)) && path.account.Match([]byte(accountName)) {
			for i := range path.operations {
				if strings.EqualFold(path.operations[i], "none") || strings.EqualFold(path.operations[i], antiOperation) {
					log.Trace().Str("result", "denied").Msg("Negative permission matched")
					return false
				}
				if strings.EqualFold(path.operations[i], "all") || strings.EqualFold(path.operations[i], operation) {
					log.Trace().Str("result", "succeeded").Msg("Positive permission matched")
					return true
				}
			}
		}
	}
	log.Trace().Str("result", "denied").Msg("No matching rules")
	return false
}
Check checks the client to see if the account is allowed.
package static
import (
	"context"
	"fmt"
	"regexp"
	"strings"
	"github.com/attestantio/dirk/services/checker"
	"github.com/attestantio/dirk/services/metrics"
	"github.com/pkg/errors"
	"github.com/rs/zerolog"
	zerologger "github.com/rs/zerolog/log"
	e2wallet "github.com/wealdtech/go-eth2-wallet"
)
type Service struct {
	monitor metrics.CheckerMonitor
	access  map[string][]*path
}
type path struct {
	wallet     *regexp.Regexp
	account    *regexp.Regexp
	operations []string
}
var log zerolog.Logger
func New(ctx context.Context, params ...Parameter) (*Service, error) {
	parameters, err := parseAndCheckParameters(params...)
	if err != nil {
		return nil, errors.Wrap(err, "problem with parameters")
	}
	log = zerologger.With().Str("service", "checker").Str("impl", "static").Logger()
	if parameters.logLevel != log.GetLevel() {
		log = log.Level(parameters.logLevel)
	}
	s := &Service{
		monitor: parameters.monitor,
		access:  parameters.access,
	}
	return s, nil
}