@@ -46,7 +46,12 @@ func (s *Server) GetAllNamedSubjects(ctx context.Context, in *pb.SimpleGetReques
4646 return & pb.ArrayReply {}, err
4747 }
4848
49- return & pb.ArrayReply {Array : e .GetModel ().GetValuesForFieldInPolicy ("p" , in .PType , 0 )}, nil
49+ valuesForFieldInPolicy , err := e .GetModel ().GetValuesForFieldInPolicy ("p" , in .PType , 0 )
50+ if err != nil {
51+ return & pb.ArrayReply {}, err
52+ }
53+
54+ return & pb.ArrayReply {Array : valuesForFieldInPolicy }, nil
5055}
5156
5257// GetAllObjects gets the list of objects that show up in the current policy.
@@ -61,7 +66,12 @@ func (s *Server) GetAllNamedObjects(ctx context.Context, in *pb.SimpleGetRequest
6166 return & pb.ArrayReply {}, err
6267 }
6368
64- return & pb.ArrayReply {Array : e .GetModel ().GetValuesForFieldInPolicy ("p" , in .PType , 1 )}, nil
69+ valuesForFieldInPolicy , err := e .GetModel ().GetValuesForFieldInPolicy ("p" , in .PType , 1 )
70+ if err != nil {
71+ return & pb.ArrayReply {}, err
72+ }
73+
74+ return & pb.ArrayReply {Array : valuesForFieldInPolicy }, nil
6575}
6676
6777// GetAllActions gets the list of actions that show up in the current policy.
@@ -76,7 +86,12 @@ func (s *Server) GetAllNamedActions(ctx context.Context, in *pb.SimpleGetRequest
7686 return & pb.ArrayReply {}, err
7787 }
7888
79- return & pb.ArrayReply {Array : e .GetModel ().GetValuesForFieldInPolicy ("p" , in .PType , 2 )}, nil
89+ valuesForFieldInPolicy , err := e .GetModel ().GetValuesForFieldInPolicy ("p" , in .PType , 2 )
90+ if err != nil {
91+ return & pb.ArrayReply {}, err
92+ }
93+
94+ return & pb.ArrayReply {Array : valuesForFieldInPolicy }, nil
8095}
8196
8297// GetAllRoles gets the list of roles that show up in the current policy.
@@ -91,7 +106,12 @@ func (s *Server) GetAllNamedRoles(ctx context.Context, in *pb.SimpleGetRequest)
91106 return & pb.ArrayReply {}, err
92107 }
93108
94- return & pb.ArrayReply {Array : e .GetModel ().GetValuesForFieldInPolicy ("g" , in .PType , 1 )}, nil
109+ valuesForFieldInPolicy , err := e .GetModel ().GetValuesForFieldInPolicy ("g" , in .PType , 1 )
110+ if err != nil {
111+ return & pb.ArrayReply {}, err
112+ }
113+
114+ return & pb.ArrayReply {Array : valuesForFieldInPolicy }, nil
95115}
96116
97117// GetPolicy gets all the authorization rules in the policy.
@@ -106,7 +126,12 @@ func (s *Server) GetNamedPolicy(ctx context.Context, in *pb.PolicyRequest) (*pb.
106126 return & pb.Array2DReply {}, err
107127 }
108128
109- return s .wrapPlainPolicy (e .GetModel ().GetPolicy ("p" , in .PType )), nil
129+ policy , err := e .GetModel ().GetPolicy ("p" , in .PType )
130+ if err != nil {
131+ return & pb.Array2DReply {}, err
132+ }
133+
134+ return s .wrapPlainPolicy (policy ), nil
110135}
111136
112137// GetFilteredPolicy gets all the authorization rules in the policy, field filters can be specified.
@@ -123,7 +148,12 @@ func (s *Server) GetFilteredNamedPolicy(ctx context.Context, in *pb.FilteredPoli
123148 return & pb.Array2DReply {}, err
124149 }
125150
126- return s .wrapPlainPolicy (e .GetModel ().GetFilteredPolicy ("p" , in .PType , int (in .FieldIndex ), in .FieldValues ... )), nil
151+ filteredPolicy , err := e .GetModel ().GetFilteredPolicy ("p" , in .PType , int (in .FieldIndex ), in .FieldValues ... )
152+ if err != nil {
153+ return & pb.Array2DReply {}, err
154+ }
155+
156+ return s .wrapPlainPolicy (filteredPolicy ), nil
127157}
128158
129159// GetGroupingPolicy gets all the role inheritance rules in the policy.
@@ -138,7 +168,12 @@ func (s *Server) GetNamedGroupingPolicy(ctx context.Context, in *pb.PolicyReques
138168 return & pb.Array2DReply {}, err
139169 }
140170
141- return s .wrapPlainPolicy (e .GetModel ().GetPolicy ("g" , in .PType )), nil
171+ policy , err := e .GetModel ().GetPolicy ("g" , in .PType )
172+ if err != nil {
173+ return & pb.Array2DReply {}, err
174+ }
175+
176+ return s .wrapPlainPolicy (policy ), nil
142177}
143178
144179// GetFilteredGroupingPolicy gets all the role inheritance rules in the policy, field filters can be specified.
@@ -155,7 +190,12 @@ func (s *Server) GetFilteredNamedGroupingPolicy(ctx context.Context, in *pb.Filt
155190 return & pb.Array2DReply {}, err
156191 }
157192
158- return s .wrapPlainPolicy (e .GetModel ().GetFilteredPolicy ("g" , in .PType , int (in .FieldIndex ), in .FieldValues ... )), nil
193+ filteredPolicy , err := e .GetModel ().GetFilteredPolicy ("g" , in .PType , int (in .FieldIndex ), in .FieldValues ... )
194+ if err != nil {
195+ return & pb.Array2DReply {}, err
196+ }
197+
198+ return s .wrapPlainPolicy (filteredPolicy ), nil
159199}
160200
161201// HasPolicy determines whether an authorization rule exists.
@@ -170,7 +210,12 @@ func (s *Server) HasNamedPolicy(ctx context.Context, in *pb.PolicyRequest) (*pb.
170210 return & pb.BoolReply {}, err
171211 }
172212
173- return & pb.BoolReply {Res : e .GetModel ().HasPolicy ("p" , in .PType , in .Params )}, nil
213+ hasPolicy , err := e .GetModel ().HasPolicy ("p" , in .PType , in .Params )
214+ if err != nil {
215+ return & pb.BoolReply {}, err
216+ }
217+
218+ return & pb.BoolReply {Res : hasPolicy }, nil
174219}
175220
176221// HasGroupingPolicy determines whether a role inheritance rule exists.
@@ -186,7 +231,12 @@ func (s *Server) HasNamedGroupingPolicy(ctx context.Context, in *pb.PolicyReques
186231 return & pb.BoolReply {}, err
187232 }
188233
189- return & pb.BoolReply {Res : e .GetModel ().HasPolicy ("g" , in .PType , in .Params )}, nil
234+ haPolicy , err := e .GetModel ().HasPolicy ("g" , in .PType , in .Params )
235+ if err != nil {
236+ return & pb.BoolReply {}, err
237+ }
238+
239+ return & pb.BoolReply {Res : haPolicy }, nil
190240}
191241
192242func (s * Server ) AddPolicy (ctx context.Context , in * pb.PolicyRequest ) (* pb.BoolReply , error ) {
0 commit comments