MCPcopy Create free account
hub / github.com/couchbase/cbft / preparePerms

Function preparePerms

rest_auth.go:434–459  ·  view source on GitHub ↗
(mgr definitionLookuper, r requestParser,
	method, path string)

Source from the content-addressed store, hash-verified

432}
433
434func preparePerms(mgr definitionLookuper, r requestParser,
435 method, path string) ([]string, error) {
436 perm := restPermsMap[method+":"+path]
437 if perm == "" {
438 perm = restPermDefault
439 } else if perm == "none" {
440 return nil, nil
441 } else if strings.Index(perm, "{}") >= 0 {
442 return nil, nil // Need dynamic post-filtering of REST response.
443 }
444 if strings.Index(perm, "<sourceName>") >= 0 {
445 sourceNames, err := sourceNamesFromReq(mgr, r, method, path)
446 if err != nil {
447 return nil, err
448 }
449
450 perms := make([]string, 0, len(sourceNames))
451 for _, sourceName := range sourceNames {
452 perms = append(perms,
453 decoratePermStrings(perm, sourceName))
454 }
455 return perms, nil
456 }
457
458 return []string{perm}, nil
459}
460
461func decoratePermStrings(perm, sourceName string) string {
462 // If the RBAC settings are done at the scope or collection

Callers 5

authenticateMethod · 0.85
checkAPIAuthFunction · 0.85
TestPreparePermsFunction · 0.85
TestFilteredListIndexesFunction · 0.85
TestPingAuthFunction · 0.85

Calls 3

sourceNamesFromReqFunction · 0.85
decoratePermStringsFunction · 0.85
IndexMethod · 0.45

Tested by 3

TestPreparePermsFunction · 0.68
TestFilteredListIndexesFunction · 0.68
TestPingAuthFunction · 0.68