| 164 | } |
| 165 | |
| 166 | func (s *Server) Enforce(ctx context.Context, in *pb.EnforceRequest) (*pb.BoolReply, error) { |
| 167 | e, err := s.getEnforcer(int(in.EnforcerHandler)) |
| 168 | if err != nil { |
| 169 | return &pb.BoolReply{Res: false}, err |
| 170 | } |
| 171 | var param interface{} |
| 172 | params := make([]interface{}, 0, len(in.Params)) |
| 173 | m := e.GetModel()["m"]["m"].Value |
| 174 | |
| 175 | for index := range in.Params { |
| 176 | param, m = s.parseParam(in.Params[index], m) |
| 177 | params = append(params, param) |
| 178 | } |
| 179 | |
| 180 | res, err := e.EnforceWithMatcher(m, params...) |
| 181 | if err != nil { |
| 182 | return &pb.BoolReply{Res: false}, err |
| 183 | } |
| 184 | |
| 185 | return &pb.BoolReply{Res: res}, nil |
| 186 | } |
| 187 | |
| 188 | func (s *Server) LoadPolicy(ctx context.Context, in *pb.EmptyRequest) (*pb.EmptyReply, error) { |
| 189 | e, err := s.getEnforcer(int(in.Handler)) |