MCPcopy Create free account
hub / github.com/cloudwan/gohan / authorization

Function authorization

server/api.go:42–54  ·  view source on GitHub ↗
(w http.ResponseWriter, r *http.Request, action, path string, s *schema.Schema, auth schema.Authorization)

Source from the content-addressed store, hash-verified

40)
41
42func authorization(w http.ResponseWriter, r *http.Request, action, path string, s *schema.Schema, auth schema.Authorization) (*schema.Policy, *schema.Role) {
43 manager := schema.GetManager()
44 log.Debug("[authorization*] %s %v", action, auth)
45 if auth == nil {
46 return schema.NewEmptyPolicy(), nil
47 }
48 policy, role := manager.PolicyValidate(action, path, auth)
49 if policy == nil {
50 log.Debug("No policy match: %s %s", action, path)
51 return nil, nil
52 }
53 return policy, role
54}
55
56func addParamToQuery(r *http.Request, key, value string) {
57 r.URL.RawQuery += "&" + key + "=" + value

Callers 1

MapRouteBySchemasFunction · 0.85

Calls 2

PolicyValidateMethod · 0.80
DebugMethod · 0.65

Tested by

no test coverage detected