MCPcopy
hub / github.com/apache/casbin / HasPolicy

Method HasPolicy

model/policy.go:172–179  ·  view source on GitHub ↗

HasPolicy determines whether a model has the specified policy rule.

(sec string, ptype string, rule []string)

Source from the content-addressed store, hash-verified

170
171// HasPolicy determines whether a model has the specified policy rule.
172func (model Model) HasPolicy(sec string, ptype string, rule []string) (bool, error) {
173 _, err := model.GetAssertion(sec, ptype)
174 if err != nil {
175 return false, err
176 }
177 _, ok := model[sec][ptype].PolicyMap[strings.Join(rule, DefaultSep)]
178 return ok, nil
179}
180
181// HasPolicies determines whether a model has any of the specified policies. If one is found we return true.
182func (model Model) HasPolicies(sec string, ptype string, rules [][]string) (bool, error) {

Callers 2

HasPolicyExMethod · 0.95
HasPoliciesMethod · 0.95

Calls 1

GetAssertionMethod · 0.95

Tested by

no test coverage detected