MCPcopy
hub / github.com/grpc/grpc-go / parseRequest

Function parseRequest

authz/rbac_translator.go:248–268  ·  view source on GitHub ↗
(request request)

Source from the content-addressed store, hash-verified

246}
247
248func parseRequest(request request) (*v3rbacpb.Permission, error) {
249 var and []*v3rbacpb.Permission
250 if len(request.Paths) > 0 {
251 and = append(and, permissionOr(parsePaths(request.Paths)))
252 }
253 if len(request.Headers) > 0 {
254 headers, err := parseHeaders(request.Headers)
255 if err != nil {
256 return nil, err
257 }
258 and = append(and, permissionAnd(headers))
259 }
260 if len(and) > 0 {
261 return permissionAnd(and), nil
262 }
263 return &v3rbacpb.Permission{
264 Rule: &v3rbacpb.Permission_Any{
265 Any: true,
266 },
267 }, nil
268}
269
270func parseRules(rules []rule, prefixName string) (map[string]*v3rbacpb.Policy, error) {
271 policies := make(map[string]*v3rbacpb.Policy)

Callers 1

parseRulesFunction · 0.85

Calls 4

permissionOrFunction · 0.85
parsePathsFunction · 0.85
parseHeadersFunction · 0.85
permissionAndFunction · 0.85

Tested by

no test coverage detected