From 138d465b85c83ee804122c3b50b5000163d836c8 Mon Sep 17 00:00:00 2001 From: Bakhdaulet Date: Wed, 4 Oct 2023 18:44:21 +0600 Subject: [PATCH] fix: add GetDomains() API (#107) * feat: get roles, permission by domains * feat: gets the domains that a user has --- proto/casbin.pb.go | 288 ++++++++++++++++++++-------------------- proto/casbin.proto | 2 + proto/casbin_grpc.pb.go | 54 ++++++++ server/rbac_api.go | 17 +++ 4 files changed, 220 insertions(+), 141 deletions(-) diff --git a/proto/casbin.pb.go b/proto/casbin.pb.go index 03d9e06..bee4ab0 100644 --- a/proto/casbin.pb.go +++ b/proto/casbin.pb.go @@ -995,7 +995,7 @@ var file_proto_casbin_proto_rawDesc = []byte{ 0x15, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x41, 0x72, 0x72, 0x61, 0x79, 0x32, 0x44, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x2e, 0x64, 0x52, 0x02, 0x64, 0x32, 0x1a, 0x13, 0x0a, 0x01, 0x64, 0x12, 0x0e, 0x0a, 0x02, 0x64, 0x31, 0x18, 0x01, 0x20, 0x03, 0x28, 0x09, 0x52, 0x02, 0x64, 0x31, 0x32, - 0xda, 0x1b, 0x0a, 0x06, 0x43, 0x61, 0x73, 0x62, 0x69, 0x6e, 0x12, 0x43, 0x0a, 0x0b, 0x4e, 0x65, + 0x95, 0x1c, 0x0a, 0x06, 0x43, 0x61, 0x73, 0x62, 0x69, 0x6e, 0x12, 0x43, 0x0a, 0x0b, 0x4e, 0x65, 0x77, 0x45, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x12, 0x19, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4e, 0x65, 0x77, 0x45, 0x6e, 0x66, 0x6f, 0x72, 0x63, 0x65, 0x72, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x17, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x4e, 0x65, 0x77, @@ -1149,79 +1149,83 @@ var file_proto_casbin_proto_rawDesc = []byte{ 0x69, 0x6e, 0x67, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x12, 0x14, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x6f, 0x6c, 0x69, 0x63, 0x79, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x10, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x42, 0x6f, 0x6f, 0x6c, 0x52, 0x65, 0x70, 0x6c, - 0x79, 0x22, 0x00, 0x12, 0x3e, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x52, 0x6f, 0x6c, 0x65, 0x73, 0x46, - 0x6f, 0x72, 0x55, 0x73, 0x65, 0x72, 0x12, 0x16, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x55, - 0x73, 0x65, 0x72, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x41, 0x72, 0x72, 0x61, 0x79, 0x52, 0x65, 0x70, 0x6c, - 0x79, 0x22, 0x00, 0x12, 0x46, 0x0a, 0x17, 0x47, 0x65, 0x74, 0x49, 0x6d, 0x70, 0x6c, 0x69, 0x63, - 0x69, 0x74, 0x52, 0x6f, 0x6c, 0x65, 0x73, 0x46, 0x6f, 0x72, 0x55, 0x73, 0x65, 0x72, 0x12, 0x16, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x6f, 0x6c, 0x65, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x41, - 0x72, 0x72, 0x61, 0x79, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x3e, 0x0a, 0x0f, 0x47, - 0x65, 0x74, 0x55, 0x73, 0x65, 0x72, 0x73, 0x46, 0x6f, 0x72, 0x52, 0x6f, 0x6c, 0x65, 0x12, 0x16, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x6f, 0x6c, 0x65, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x41, - 0x72, 0x72, 0x61, 0x79, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x3c, 0x0a, 0x0e, 0x48, - 0x61, 0x73, 0x52, 0x6f, 0x6c, 0x65, 0x46, 0x6f, 0x72, 0x55, 0x73, 0x65, 0x72, 0x12, 0x16, 0x2e, - 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x65, - 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x10, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x42, 0x6f, - 0x6f, 0x6c, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x3c, 0x0a, 0x0e, 0x41, 0x64, 0x64, - 0x52, 0x6f, 0x6c, 0x65, 0x46, 0x6f, 0x72, 0x55, 0x73, 0x65, 0x72, 0x12, 0x16, 0x2e, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, - 0x65, 0x73, 0x74, 0x1a, 0x10, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x42, 0x6f, 0x6f, 0x6c, - 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x3f, 0x0a, 0x11, 0x44, 0x65, 0x6c, 0x65, 0x74, - 0x65, 0x52, 0x6f, 0x6c, 0x65, 0x46, 0x6f, 0x72, 0x55, 0x73, 0x65, 0x72, 0x12, 0x16, 0x2e, 0x70, - 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x1a, 0x10, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x42, 0x6f, 0x6f, - 0x6c, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x40, 0x0a, 0x12, 0x44, 0x65, 0x6c, 0x65, - 0x74, 0x65, 0x52, 0x6f, 0x6c, 0x65, 0x73, 0x46, 0x6f, 0x72, 0x55, 0x73, 0x65, 0x72, 0x12, 0x16, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x6f, 0x6c, 0x65, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x10, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x42, - 0x6f, 0x6f, 0x6c, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x38, 0x0a, 0x0a, 0x44, 0x65, - 0x6c, 0x65, 0x74, 0x65, 0x55, 0x73, 0x65, 0x72, 0x12, 0x16, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, + 0x79, 0x22, 0x00, 0x12, 0x39, 0x0a, 0x0a, 0x47, 0x65, 0x74, 0x44, 0x6f, 0x6d, 0x61, 0x69, 0x6e, + 0x73, 0x12, 0x16, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x6f, + 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x2e, 0x41, 0x72, 0x72, 0x61, 0x79, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x3e, + 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x52, 0x6f, 0x6c, 0x65, 0x73, 0x46, 0x6f, 0x72, 0x55, 0x73, 0x65, + 0x72, 0x12, 0x16, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x6f, + 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x2e, 0x41, 0x72, 0x72, 0x61, 0x79, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x46, + 0x0a, 0x17, 0x47, 0x65, 0x74, 0x49, 0x6d, 0x70, 0x6c, 0x69, 0x63, 0x69, 0x74, 0x52, 0x6f, 0x6c, + 0x65, 0x73, 0x46, 0x6f, 0x72, 0x55, 0x73, 0x65, 0x72, 0x12, 0x16, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x11, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x41, 0x72, 0x72, 0x61, 0x79, 0x52, + 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x3e, 0x0a, 0x0f, 0x47, 0x65, 0x74, 0x55, 0x73, 0x65, + 0x72, 0x73, 0x46, 0x6f, 0x72, 0x52, 0x6f, 0x6c, 0x65, 0x12, 0x16, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x11, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x41, 0x72, 0x72, 0x61, 0x79, 0x52, + 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x3c, 0x0a, 0x0e, 0x48, 0x61, 0x73, 0x52, 0x6f, 0x6c, + 0x65, 0x46, 0x6f, 0x72, 0x55, 0x73, 0x65, 0x72, 0x12, 0x16, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x10, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x42, 0x6f, 0x6f, 0x6c, 0x52, 0x65, 0x70, - 0x6c, 0x79, 0x22, 0x00, 0x12, 0x39, 0x0a, 0x0a, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x6f, - 0x6c, 0x65, 0x12, 0x16, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, - 0x6f, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x2e, 0x45, 0x6d, 0x70, 0x74, 0x79, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, - 0x48, 0x0a, 0x15, 0x47, 0x65, 0x74, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, - 0x73, 0x46, 0x6f, 0x72, 0x55, 0x73, 0x65, 0x72, 0x12, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x2e, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x41, 0x72, 0x72, 0x61, 0x79, - 0x32, 0x44, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x50, 0x0a, 0x1d, 0x47, 0x65, 0x74, - 0x49, 0x6d, 0x70, 0x6c, 0x69, 0x63, 0x69, 0x74, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, - 0x6f, 0x6e, 0x73, 0x46, 0x6f, 0x72, 0x55, 0x73, 0x65, 0x72, 0x12, 0x18, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x2e, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, - 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x41, 0x72, 0x72, - 0x61, 0x79, 0x32, 0x44, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x40, 0x0a, 0x10, 0x44, - 0x65, 0x6c, 0x65, 0x74, 0x65, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x12, - 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, - 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x10, 0x2e, 0x70, 0x72, 0x6f, 0x74, - 0x6f, 0x2e, 0x42, 0x6f, 0x6f, 0x6c, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x44, 0x0a, - 0x14, 0x41, 0x64, 0x64, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x46, 0x6f, + 0x6c, 0x79, 0x22, 0x00, 0x12, 0x3c, 0x0a, 0x0e, 0x41, 0x64, 0x64, 0x52, 0x6f, 0x6c, 0x65, 0x46, + 0x6f, 0x72, 0x55, 0x73, 0x65, 0x72, 0x12, 0x16, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x55, + 0x73, 0x65, 0x72, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x10, + 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x42, 0x6f, 0x6f, 0x6c, 0x52, 0x65, 0x70, 0x6c, 0x79, + 0x22, 0x00, 0x12, 0x3f, 0x0a, 0x11, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x6f, 0x6c, 0x65, + 0x46, 0x6f, 0x72, 0x55, 0x73, 0x65, 0x72, 0x12, 0x16, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, + 0x55, 0x73, 0x65, 0x72, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, + 0x10, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x42, 0x6f, 0x6f, 0x6c, 0x52, 0x65, 0x70, 0x6c, + 0x79, 0x22, 0x00, 0x12, 0x40, 0x0a, 0x12, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x6f, 0x6c, + 0x65, 0x73, 0x46, 0x6f, 0x72, 0x55, 0x73, 0x65, 0x72, 0x12, 0x16, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, + 0x74, 0x1a, 0x10, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x42, 0x6f, 0x6f, 0x6c, 0x52, 0x65, + 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x38, 0x0a, 0x0a, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x55, + 0x73, 0x65, 0x72, 0x12, 0x16, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x55, 0x73, 0x65, 0x72, + 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x10, 0x2e, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x2e, 0x42, 0x6f, 0x6f, 0x6c, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, + 0x39, 0x0a, 0x0a, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x6f, 0x6c, 0x65, 0x12, 0x16, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x55, 0x73, 0x65, 0x72, 0x52, 0x6f, 0x6c, 0x65, 0x52, 0x65, + 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x45, 0x6d, + 0x70, 0x74, 0x79, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x48, 0x0a, 0x15, 0x47, 0x65, + 0x74, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x46, 0x6f, 0x72, 0x55, + 0x73, 0x65, 0x72, 0x12, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x65, 0x72, 0x6d, + 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x13, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x41, 0x72, 0x72, 0x61, 0x79, 0x32, 0x44, 0x52, 0x65, 0x70, + 0x6c, 0x79, 0x22, 0x00, 0x12, 0x50, 0x0a, 0x1d, 0x47, 0x65, 0x74, 0x49, 0x6d, 0x70, 0x6c, 0x69, + 0x63, 0x69, 0x74, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x46, 0x6f, 0x72, 0x55, 0x73, 0x65, 0x72, 0x12, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, - 0x10, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x42, 0x6f, 0x6f, 0x6c, 0x52, 0x65, 0x70, 0x6c, - 0x79, 0x22, 0x00, 0x12, 0x47, 0x0a, 0x17, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x50, 0x65, 0x72, - 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x46, 0x6f, 0x72, 0x55, 0x73, 0x65, 0x72, 0x12, 0x18, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, - 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x10, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x2e, 0x42, 0x6f, 0x6f, 0x6c, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x48, 0x0a, 0x18, - 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, - 0x73, 0x46, 0x6f, 0x72, 0x55, 0x73, 0x65, 0x72, 0x12, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x2e, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, - 0x73, 0x74, 0x1a, 0x10, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x42, 0x6f, 0x6f, 0x6c, 0x52, - 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x44, 0x0a, 0x14, 0x48, 0x61, 0x73, 0x50, 0x65, 0x72, - 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x46, 0x6f, 0x72, 0x55, 0x73, 0x65, 0x72, 0x12, 0x18, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, - 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x10, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x2e, 0x42, 0x6f, 0x6f, 0x6c, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x42, 0x42, 0x0a, 0x16, - 0x69, 0x6f, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, - 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x42, 0x0b, 0x43, 0x61, 0x73, 0x62, 0x69, 0x6e, 0x50, 0x72, - 0x6f, 0x74, 0x6f, 0x50, 0x01, 0x5a, 0x08, 0x2e, 0x2f, 0x3b, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0xaa, - 0x02, 0x0e, 0x43, 0x61, 0x73, 0x62, 0x69, 0x6e, 0x4f, 0x72, 0x67, 0x2e, 0x47, 0x72, 0x70, 0x63, - 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, + 0x13, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x41, 0x72, 0x72, 0x61, 0x79, 0x32, 0x44, 0x52, + 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x40, 0x0a, 0x10, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, + 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x12, 0x18, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x2e, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, + 0x75, 0x65, 0x73, 0x74, 0x1a, 0x10, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x42, 0x6f, 0x6f, + 0x6c, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x44, 0x0a, 0x14, 0x41, 0x64, 0x64, 0x50, + 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x46, 0x6f, 0x72, 0x55, 0x73, 0x65, 0x72, + 0x12, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, + 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x10, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x2e, 0x42, 0x6f, 0x6f, 0x6c, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x47, + 0x0a, 0x17, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, + 0x6f, 0x6e, 0x46, 0x6f, 0x72, 0x55, 0x73, 0x65, 0x72, 0x12, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x2e, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x10, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x42, 0x6f, 0x6f, 0x6c, + 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x12, 0x48, 0x0a, 0x18, 0x44, 0x65, 0x6c, 0x65, 0x74, + 0x65, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x46, 0x6f, 0x72, 0x55, + 0x73, 0x65, 0x72, 0x12, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x50, 0x65, 0x72, 0x6d, + 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x10, 0x2e, + 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x42, 0x6f, 0x6f, 0x6c, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, + 0x00, 0x12, 0x44, 0x0a, 0x14, 0x48, 0x61, 0x73, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, + 0x6f, 0x6e, 0x46, 0x6f, 0x72, 0x55, 0x73, 0x65, 0x72, 0x12, 0x18, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x2e, 0x50, 0x65, 0x72, 0x6d, 0x69, 0x73, 0x73, 0x69, 0x6f, 0x6e, 0x52, 0x65, 0x71, 0x75, + 0x65, 0x73, 0x74, 0x1a, 0x10, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x42, 0x6f, 0x6f, 0x6c, + 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x42, 0x42, 0x0a, 0x16, 0x69, 0x6f, 0x2e, 0x67, 0x72, + 0x70, 0x63, 0x2e, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x70, 0x72, 0x6f, 0x74, + 0x6f, 0x42, 0x0b, 0x43, 0x61, 0x73, 0x62, 0x69, 0x6e, 0x50, 0x72, 0x6f, 0x74, 0x6f, 0x50, 0x01, + 0x5a, 0x08, 0x2e, 0x2f, 0x3b, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0xaa, 0x02, 0x0e, 0x43, 0x61, 0x73, + 0x62, 0x69, 0x6e, 0x4f, 0x72, 0x67, 0x2e, 0x47, 0x72, 0x70, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x33, } var ( @@ -1294,77 +1298,79 @@ var file_proto_casbin_proto_depIdxs = []int32{ 8, // 35: proto.Casbin.HasNamedPolicy:input_type -> proto.PolicyRequest 8, // 36: proto.Casbin.HasGroupingPolicy:input_type -> proto.PolicyRequest 8, // 37: proto.Casbin.HasNamedGroupingPolicy:input_type -> proto.PolicyRequest - 12, // 38: proto.Casbin.GetRolesForUser:input_type -> proto.UserRoleRequest - 12, // 39: proto.Casbin.GetImplicitRolesForUser:input_type -> proto.UserRoleRequest - 12, // 40: proto.Casbin.GetUsersForRole:input_type -> proto.UserRoleRequest - 12, // 41: proto.Casbin.HasRoleForUser:input_type -> proto.UserRoleRequest - 12, // 42: proto.Casbin.AddRoleForUser:input_type -> proto.UserRoleRequest - 12, // 43: proto.Casbin.DeleteRoleForUser:input_type -> proto.UserRoleRequest - 12, // 44: proto.Casbin.DeleteRolesForUser:input_type -> proto.UserRoleRequest - 12, // 45: proto.Casbin.DeleteUser:input_type -> proto.UserRoleRequest - 12, // 46: proto.Casbin.DeleteRole:input_type -> proto.UserRoleRequest - 13, // 47: proto.Casbin.GetPermissionsForUser:input_type -> proto.PermissionRequest - 13, // 48: proto.Casbin.GetImplicitPermissionsForUser:input_type -> proto.PermissionRequest - 13, // 49: proto.Casbin.DeletePermission:input_type -> proto.PermissionRequest - 13, // 50: proto.Casbin.AddPermissionForUser:input_type -> proto.PermissionRequest - 13, // 51: proto.Casbin.DeletePermissionForUser:input_type -> proto.PermissionRequest - 13, // 52: proto.Casbin.DeletePermissionsForUser:input_type -> proto.PermissionRequest - 13, // 53: proto.Casbin.HasPermissionForUser:input_type -> proto.PermissionRequest - 1, // 54: proto.Casbin.NewEnforcer:output_type -> proto.NewEnforcerReply - 3, // 55: proto.Casbin.NewAdapter:output_type -> proto.NewAdapterReply - 5, // 56: proto.Casbin.Enforce:output_type -> proto.BoolReply - 7, // 57: proto.Casbin.LoadPolicy:output_type -> proto.EmptyReply - 7, // 58: proto.Casbin.SavePolicy:output_type -> proto.EmptyReply - 5, // 59: proto.Casbin.AddPolicy:output_type -> proto.BoolReply - 5, // 60: proto.Casbin.AddNamedPolicy:output_type -> proto.BoolReply - 5, // 61: proto.Casbin.RemovePolicy:output_type -> proto.BoolReply - 5, // 62: proto.Casbin.RemoveNamedPolicy:output_type -> proto.BoolReply - 5, // 63: proto.Casbin.RemoveFilteredPolicy:output_type -> proto.BoolReply - 5, // 64: proto.Casbin.RemoveFilteredNamedPolicy:output_type -> proto.BoolReply - 14, // 65: proto.Casbin.GetPolicy:output_type -> proto.Array2DReply - 14, // 66: proto.Casbin.GetNamedPolicy:output_type -> proto.Array2DReply - 14, // 67: proto.Casbin.GetFilteredPolicy:output_type -> proto.Array2DReply - 14, // 68: proto.Casbin.GetFilteredNamedPolicy:output_type -> proto.Array2DReply - 5, // 69: proto.Casbin.AddGroupingPolicy:output_type -> proto.BoolReply - 5, // 70: proto.Casbin.AddNamedGroupingPolicy:output_type -> proto.BoolReply - 5, // 71: proto.Casbin.RemoveGroupingPolicy:output_type -> proto.BoolReply - 5, // 72: proto.Casbin.RemoveNamedGroupingPolicy:output_type -> proto.BoolReply - 5, // 73: proto.Casbin.RemoveFilteredGroupingPolicy:output_type -> proto.BoolReply - 5, // 74: proto.Casbin.RemoveFilteredNamedGroupingPolicy:output_type -> proto.BoolReply - 14, // 75: proto.Casbin.GetGroupingPolicy:output_type -> proto.Array2DReply - 14, // 76: proto.Casbin.GetNamedGroupingPolicy:output_type -> proto.Array2DReply - 14, // 77: proto.Casbin.GetFilteredGroupingPolicy:output_type -> proto.Array2DReply - 14, // 78: proto.Casbin.GetFilteredNamedGroupingPolicy:output_type -> proto.Array2DReply - 10, // 79: proto.Casbin.GetAllSubjects:output_type -> proto.ArrayReply - 10, // 80: proto.Casbin.GetAllNamedSubjects:output_type -> proto.ArrayReply - 10, // 81: proto.Casbin.GetAllObjects:output_type -> proto.ArrayReply - 10, // 82: proto.Casbin.GetAllNamedObjects:output_type -> proto.ArrayReply - 10, // 83: proto.Casbin.GetAllActions:output_type -> proto.ArrayReply - 10, // 84: proto.Casbin.GetAllNamedActions:output_type -> proto.ArrayReply - 10, // 85: proto.Casbin.GetAllRoles:output_type -> proto.ArrayReply - 10, // 86: proto.Casbin.GetAllNamedRoles:output_type -> proto.ArrayReply - 5, // 87: proto.Casbin.HasPolicy:output_type -> proto.BoolReply - 5, // 88: proto.Casbin.HasNamedPolicy:output_type -> proto.BoolReply - 5, // 89: proto.Casbin.HasGroupingPolicy:output_type -> proto.BoolReply - 5, // 90: proto.Casbin.HasNamedGroupingPolicy:output_type -> proto.BoolReply - 10, // 91: proto.Casbin.GetRolesForUser:output_type -> proto.ArrayReply - 10, // 92: proto.Casbin.GetImplicitRolesForUser:output_type -> proto.ArrayReply - 10, // 93: proto.Casbin.GetUsersForRole:output_type -> proto.ArrayReply - 5, // 94: proto.Casbin.HasRoleForUser:output_type -> proto.BoolReply - 5, // 95: proto.Casbin.AddRoleForUser:output_type -> proto.BoolReply - 5, // 96: proto.Casbin.DeleteRoleForUser:output_type -> proto.BoolReply - 5, // 97: proto.Casbin.DeleteRolesForUser:output_type -> proto.BoolReply - 5, // 98: proto.Casbin.DeleteUser:output_type -> proto.BoolReply - 7, // 99: proto.Casbin.DeleteRole:output_type -> proto.EmptyReply - 14, // 100: proto.Casbin.GetPermissionsForUser:output_type -> proto.Array2DReply - 14, // 101: proto.Casbin.GetImplicitPermissionsForUser:output_type -> proto.Array2DReply - 5, // 102: proto.Casbin.DeletePermission:output_type -> proto.BoolReply - 5, // 103: proto.Casbin.AddPermissionForUser:output_type -> proto.BoolReply - 5, // 104: proto.Casbin.DeletePermissionForUser:output_type -> proto.BoolReply - 5, // 105: proto.Casbin.DeletePermissionsForUser:output_type -> proto.BoolReply - 5, // 106: proto.Casbin.HasPermissionForUser:output_type -> proto.BoolReply - 54, // [54:107] is the sub-list for method output_type - 1, // [1:54] is the sub-list for method input_type + 12, // 38: proto.Casbin.GetDomains:input_type -> proto.UserRoleRequest + 12, // 39: proto.Casbin.GetRolesForUser:input_type -> proto.UserRoleRequest + 12, // 40: proto.Casbin.GetImplicitRolesForUser:input_type -> proto.UserRoleRequest + 12, // 41: proto.Casbin.GetUsersForRole:input_type -> proto.UserRoleRequest + 12, // 42: proto.Casbin.HasRoleForUser:input_type -> proto.UserRoleRequest + 12, // 43: proto.Casbin.AddRoleForUser:input_type -> proto.UserRoleRequest + 12, // 44: proto.Casbin.DeleteRoleForUser:input_type -> proto.UserRoleRequest + 12, // 45: proto.Casbin.DeleteRolesForUser:input_type -> proto.UserRoleRequest + 12, // 46: proto.Casbin.DeleteUser:input_type -> proto.UserRoleRequest + 12, // 47: proto.Casbin.DeleteRole:input_type -> proto.UserRoleRequest + 13, // 48: proto.Casbin.GetPermissionsForUser:input_type -> proto.PermissionRequest + 13, // 49: proto.Casbin.GetImplicitPermissionsForUser:input_type -> proto.PermissionRequest + 13, // 50: proto.Casbin.DeletePermission:input_type -> proto.PermissionRequest + 13, // 51: proto.Casbin.AddPermissionForUser:input_type -> proto.PermissionRequest + 13, // 52: proto.Casbin.DeletePermissionForUser:input_type -> proto.PermissionRequest + 13, // 53: proto.Casbin.DeletePermissionsForUser:input_type -> proto.PermissionRequest + 13, // 54: proto.Casbin.HasPermissionForUser:input_type -> proto.PermissionRequest + 1, // 55: proto.Casbin.NewEnforcer:output_type -> proto.NewEnforcerReply + 3, // 56: proto.Casbin.NewAdapter:output_type -> proto.NewAdapterReply + 5, // 57: proto.Casbin.Enforce:output_type -> proto.BoolReply + 7, // 58: proto.Casbin.LoadPolicy:output_type -> proto.EmptyReply + 7, // 59: proto.Casbin.SavePolicy:output_type -> proto.EmptyReply + 5, // 60: proto.Casbin.AddPolicy:output_type -> proto.BoolReply + 5, // 61: proto.Casbin.AddNamedPolicy:output_type -> proto.BoolReply + 5, // 62: proto.Casbin.RemovePolicy:output_type -> proto.BoolReply + 5, // 63: proto.Casbin.RemoveNamedPolicy:output_type -> proto.BoolReply + 5, // 64: proto.Casbin.RemoveFilteredPolicy:output_type -> proto.BoolReply + 5, // 65: proto.Casbin.RemoveFilteredNamedPolicy:output_type -> proto.BoolReply + 14, // 66: proto.Casbin.GetPolicy:output_type -> proto.Array2DReply + 14, // 67: proto.Casbin.GetNamedPolicy:output_type -> proto.Array2DReply + 14, // 68: proto.Casbin.GetFilteredPolicy:output_type -> proto.Array2DReply + 14, // 69: proto.Casbin.GetFilteredNamedPolicy:output_type -> proto.Array2DReply + 5, // 70: proto.Casbin.AddGroupingPolicy:output_type -> proto.BoolReply + 5, // 71: proto.Casbin.AddNamedGroupingPolicy:output_type -> proto.BoolReply + 5, // 72: proto.Casbin.RemoveGroupingPolicy:output_type -> proto.BoolReply + 5, // 73: proto.Casbin.RemoveNamedGroupingPolicy:output_type -> proto.BoolReply + 5, // 74: proto.Casbin.RemoveFilteredGroupingPolicy:output_type -> proto.BoolReply + 5, // 75: proto.Casbin.RemoveFilteredNamedGroupingPolicy:output_type -> proto.BoolReply + 14, // 76: proto.Casbin.GetGroupingPolicy:output_type -> proto.Array2DReply + 14, // 77: proto.Casbin.GetNamedGroupingPolicy:output_type -> proto.Array2DReply + 14, // 78: proto.Casbin.GetFilteredGroupingPolicy:output_type -> proto.Array2DReply + 14, // 79: proto.Casbin.GetFilteredNamedGroupingPolicy:output_type -> proto.Array2DReply + 10, // 80: proto.Casbin.GetAllSubjects:output_type -> proto.ArrayReply + 10, // 81: proto.Casbin.GetAllNamedSubjects:output_type -> proto.ArrayReply + 10, // 82: proto.Casbin.GetAllObjects:output_type -> proto.ArrayReply + 10, // 83: proto.Casbin.GetAllNamedObjects:output_type -> proto.ArrayReply + 10, // 84: proto.Casbin.GetAllActions:output_type -> proto.ArrayReply + 10, // 85: proto.Casbin.GetAllNamedActions:output_type -> proto.ArrayReply + 10, // 86: proto.Casbin.GetAllRoles:output_type -> proto.ArrayReply + 10, // 87: proto.Casbin.GetAllNamedRoles:output_type -> proto.ArrayReply + 5, // 88: proto.Casbin.HasPolicy:output_type -> proto.BoolReply + 5, // 89: proto.Casbin.HasNamedPolicy:output_type -> proto.BoolReply + 5, // 90: proto.Casbin.HasGroupingPolicy:output_type -> proto.BoolReply + 5, // 91: proto.Casbin.HasNamedGroupingPolicy:output_type -> proto.BoolReply + 10, // 92: proto.Casbin.GetDomains:output_type -> proto.ArrayReply + 10, // 93: proto.Casbin.GetRolesForUser:output_type -> proto.ArrayReply + 10, // 94: proto.Casbin.GetImplicitRolesForUser:output_type -> proto.ArrayReply + 10, // 95: proto.Casbin.GetUsersForRole:output_type -> proto.ArrayReply + 5, // 96: proto.Casbin.HasRoleForUser:output_type -> proto.BoolReply + 5, // 97: proto.Casbin.AddRoleForUser:output_type -> proto.BoolReply + 5, // 98: proto.Casbin.DeleteRoleForUser:output_type -> proto.BoolReply + 5, // 99: proto.Casbin.DeleteRolesForUser:output_type -> proto.BoolReply + 5, // 100: proto.Casbin.DeleteUser:output_type -> proto.BoolReply + 7, // 101: proto.Casbin.DeleteRole:output_type -> proto.EmptyReply + 14, // 102: proto.Casbin.GetPermissionsForUser:output_type -> proto.Array2DReply + 14, // 103: proto.Casbin.GetImplicitPermissionsForUser:output_type -> proto.Array2DReply + 5, // 104: proto.Casbin.DeletePermission:output_type -> proto.BoolReply + 5, // 105: proto.Casbin.AddPermissionForUser:output_type -> proto.BoolReply + 5, // 106: proto.Casbin.DeletePermissionForUser:output_type -> proto.BoolReply + 5, // 107: proto.Casbin.DeletePermissionsForUser:output_type -> proto.BoolReply + 5, // 108: proto.Casbin.HasPermissionForUser:output_type -> proto.BoolReply + 55, // [55:109] is the sub-list for method output_type + 1, // [1:55] is the sub-list for method input_type 1, // [1:1] is the sub-list for extension type_name 1, // [1:1] is the sub-list for extension extendee 0, // [0:1] is the sub-list for field type_name diff --git a/proto/casbin.proto b/proto/casbin.proto index cc71a4e..e25279a 100644 --- a/proto/casbin.proto +++ b/proto/casbin.proto @@ -68,6 +68,8 @@ service Casbin { rpc HasGroupingPolicy (PolicyRequest) returns (BoolReply) {} rpc HasNamedGroupingPolicy (PolicyRequest) returns (BoolReply) {} + rpc GetDomains(UserRoleRequest) returns (ArrayReply) {} + rpc GetRolesForUser (UserRoleRequest) returns (ArrayReply) {} rpc GetImplicitRolesForUser (UserRoleRequest) returns (ArrayReply) {} rpc GetUsersForRole (UserRoleRequest) returns (ArrayReply) {} diff --git a/proto/casbin_grpc.pb.go b/proto/casbin_grpc.pb.go index e09c609..0f4f42f 100644 --- a/proto/casbin_grpc.pb.go +++ b/proto/casbin_grpc.pb.go @@ -1,4 +1,22 @@ +// Copyright 2018 The casbin Authors. All Rights Reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + // Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.3.0 +// - protoc v4.24.3 +// source: proto/casbin.proto package proto @@ -55,6 +73,7 @@ type CasbinClient interface { HasNamedPolicy(ctx context.Context, in *PolicyRequest, opts ...grpc.CallOption) (*BoolReply, error) HasGroupingPolicy(ctx context.Context, in *PolicyRequest, opts ...grpc.CallOption) (*BoolReply, error) HasNamedGroupingPolicy(ctx context.Context, in *PolicyRequest, opts ...grpc.CallOption) (*BoolReply, error) + GetDomains(ctx context.Context, in *UserRoleRequest, opts ...grpc.CallOption) (*ArrayReply, error) GetRolesForUser(ctx context.Context, in *UserRoleRequest, opts ...grpc.CallOption) (*ArrayReply, error) GetImplicitRolesForUser(ctx context.Context, in *UserRoleRequest, opts ...grpc.CallOption) (*ArrayReply, error) GetUsersForRole(ctx context.Context, in *UserRoleRequest, opts ...grpc.CallOption) (*ArrayReply, error) @@ -414,6 +433,15 @@ func (c *casbinClient) HasNamedGroupingPolicy(ctx context.Context, in *PolicyReq return out, nil } +func (c *casbinClient) GetDomains(ctx context.Context, in *UserRoleRequest, opts ...grpc.CallOption) (*ArrayReply, error) { + out := new(ArrayReply) + err := c.cc.Invoke(ctx, "/proto.Casbin/GetDomains", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *casbinClient) GetRolesForUser(ctx context.Context, in *UserRoleRequest, opts ...grpc.CallOption) (*ArrayReply, error) { out := new(ArrayReply) err := c.cc.Invoke(ctx, "/proto.Casbin/GetRolesForUser", in, out, opts...) @@ -599,6 +627,7 @@ type CasbinServer interface { HasNamedPolicy(context.Context, *PolicyRequest) (*BoolReply, error) HasGroupingPolicy(context.Context, *PolicyRequest) (*BoolReply, error) HasNamedGroupingPolicy(context.Context, *PolicyRequest) (*BoolReply, error) + GetDomains(context.Context, *UserRoleRequest) (*ArrayReply, error) GetRolesForUser(context.Context, *UserRoleRequest) (*ArrayReply, error) GetImplicitRolesForUser(context.Context, *UserRoleRequest) (*ArrayReply, error) GetUsersForRole(context.Context, *UserRoleRequest) (*ArrayReply, error) @@ -732,6 +761,9 @@ func (UnimplementedCasbinServer) HasGroupingPolicy(context.Context, *PolicyReque func (UnimplementedCasbinServer) HasNamedGroupingPolicy(context.Context, *PolicyRequest) (*BoolReply, error) { return nil, status.Errorf(codes.Unimplemented, "method HasNamedGroupingPolicy not implemented") } +func (UnimplementedCasbinServer) GetDomains(context.Context, *UserRoleRequest) (*ArrayReply, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetDomains not implemented") +} func (UnimplementedCasbinServer) GetRolesForUser(context.Context, *UserRoleRequest) (*ArrayReply, error) { return nil, status.Errorf(codes.Unimplemented, "method GetRolesForUser not implemented") } @@ -1458,6 +1490,24 @@ func _Casbin_HasNamedGroupingPolicy_Handler(srv interface{}, ctx context.Context return interceptor(ctx, in, info, handler) } +func _Casbin_GetDomains_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(UserRoleRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(CasbinServer).GetDomains(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/proto.Casbin/GetDomains", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(CasbinServer).GetDomains(ctx, req.(*UserRoleRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _Casbin_GetRolesForUser_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(UserRoleRequest) if err := dec(in); err != nil { @@ -1901,6 +1951,10 @@ var Casbin_ServiceDesc = grpc.ServiceDesc{ MethodName: "HasNamedGroupingPolicy", Handler: _Casbin_HasNamedGroupingPolicy_Handler, }, + { + MethodName: "GetDomains", + Handler: _Casbin_GetDomains_Handler, + }, { MethodName: "GetRolesForUser", Handler: _Casbin_GetRolesForUser_Handler, diff --git a/server/rbac_api.go b/server/rbac_api.go index abeaca9..b6b8391 100644 --- a/server/rbac_api.go +++ b/server/rbac_api.go @@ -21,6 +21,23 @@ import ( pb "github.com/casbin/casbin-server/proto" ) +// GetDomains gets the domains that a user has. +func (s *Server) GetDomains(ctx context.Context, in *pb.UserRoleRequest) (*pb.ArrayReply, error) { + e, err := s.getEnforcer(int(in.EnforcerHandler)) + if err != nil { + return &pb.ArrayReply{}, err + } + + rm := e.GetModel()["g"]["g"].RM + if rm == nil { + return nil, errors.New("RoleManager is nil") + } + + res, _ := rm.GetDomains(in.User) + + return &pb.ArrayReply{Array: res}, nil +} + // GetRolesForUser gets the roles that a user has. func (s *Server) GetRolesForUser(ctx context.Context, in *pb.UserRoleRequest) (*pb.ArrayReply, error) { e, err := s.getEnforcer(int(in.EnforcerHandler))