func ProvideAuthInterceptor(
	connector *oidc.Connector,
	logger *log.Logger,
	tokens token.TokensServer,
) (*AuthInterceptor, error) {
	reqs := make(map[string]*capabilities.Rule)
	protoregistry.GlobalFiles.RangeFiles(func(fd protoreflect.FileDescriptor) bool {
		for svcs, i := fd.Services(), 0; i < svcs.Len(); i++ {
			svc := svcs.Get(i)
			for ms, j := svc.Methods(), 0; j < ms.Len(); j++ {
				m := ms.Get(j)
				req := proto.GetExtension(m.Options(), capabilities.E_MethodRule).(*capabilities.Rule)
				if req.ProtoReflect().IsValid() {
					key := fmt.Sprintf("/%s/%s", svc.FullName(), m.Name())
					logger.Tracef("found requirement %s: %s", key, req)
					reqs[key] = req
				}
			}
		}
		return true
	})
	reqs["/grpc.reflection.v1alpha.ServerReflection/ServerReflectionInfo"] =
		&capabilities.Rule{Kind: &capabilities.Rule_AuthStatus_{AuthStatus: capabilities.Rule_PUBLIC}}
	return &AuthInterceptor{
		Connector:   connector,
		Logger:      logger,
		Tokens:      tokens,
		methodRules: reqs,
	}, nil
}
ProvideAuthInterceptor is called by wire.
package rpc
import (
	"context"
	"fmt"
	"strings"
	"github.com/Mandala/go-log"
	"github.com/bobvawter/cacheroach/api/capabilities"
	"github.com/bobvawter/cacheroach/api/session"
	"github.com/bobvawter/cacheroach/api/token"
	"github.com/bobvawter/cacheroach/pkg/enforcer"
	"github.com/bobvawter/cacheroach/pkg/server/oidc"
	"google.golang.org/grpc"
	"google.golang.org/grpc/codes"
	"google.golang.org/grpc/metadata"
	"google.golang.org/grpc/status"
	"google.golang.org/protobuf/proto"
	"google.golang.org/protobuf/reflect/protoreflect"
	"google.golang.org/protobuf/reflect/protoregistry"
)
var defaultRule = &capabilities.Rule{Kind: &capabilities.Rule_AuthStatus_{
	AuthStatus: capabilities.Rule_SUPER}}
type AuthInterceptor struct {
	Connector *oidc.Connector
	Enforcer  *enforcer.Enforcer
	Logger    *log.Logger
	Tokens    token.TokensServer
	methodRules map[string]*capabilities.Rule
}