diff options
Diffstat (limited to 'pkg/authz/remote_check_service.go')
| -rw-r--r-- | pkg/authz/remote_check_service.go | 28 |
1 files changed, 28 insertions, 0 deletions
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) +} |
