From 9edd3e64a6f1a56798e3881a6e404dba7c47c0da Mon Sep 17 00:00:00 2001 From: mo khan Date: Fri, 11 Jul 2025 14:09:50 -0600 Subject: chore: split the RemoteCheckService from the LocalCheckService --- pkg/authz/remote_check_service.go | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 pkg/authz/remote_check_service.go (limited to 'pkg/authz/remote_check_service.go') diff --git a/pkg/authz/remote_check_service.go b/pkg/authz/remote_check_service.go new file mode 100644 index 0000000..43178fe --- /dev/null +++ b/pkg/authz/remote_check_service.go @@ -0,0 +1,28 @@ +package authz + +import ( + "context" + "errors" + + auth "github.com/envoyproxy/go-control-plane/envoy/service/auth/v3" + "github.com/xlgmokha/x/pkg/x" +) + +type RemoteCheckService struct { + client auth.AuthorizationClient + auth.UnimplementedAuthorizationServer +} + +func NewRemoteCheckService(client auth.AuthorizationClient) auth.AuthorizationServer { + return &RemoteCheckService{ + client: client, + } +} + +func (svc *RemoteCheckService) Check(ctx context.Context, request *auth.CheckRequest) (*auth.CheckResponse, error) { + if x.IsZero(svc.client) { + return nil, errors.New("RPC client is not configured") + } + + return svc.client.Check(ctx, request) +} -- cgit v1.2.3