diff options
Diffstat (limited to 'pkg/rpc/ability_handler.go')
| -rw-r--r-- | pkg/rpc/ability_handler.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/pkg/rpc/ability_handler.go b/pkg/rpc/ability_handler.go new file mode 100644 index 00000000..a881b41b --- /dev/null +++ b/pkg/rpc/ability_handler.go @@ -0,0 +1,20 @@ +package rpc + +import ( + context "context" + "net/http" + + "github.com/xlgmokha/x/pkg/x" + "gitlab.com/mokhax/spike/pkg/authz" +) + +type AbilityHandler struct { + authorizer authz.Authorizer + UnimplementedAbilityServer +} + +func (h *AbilityHandler) Allowed(ctx context.Context, req *AllowRequest) (*AllowReply, error) { + // TODO:: Replace http.Request with authz.Request + request := x.Must(http.NewRequestWithContext(ctx, req.Permission, req.Resource, nil)) + return &AllowReply{Result: h.authorizer.Authorize(request)}, nil +} |
