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

Method HasNamedPolicy

management_api.go:220–231  ·  view source on GitHub ↗

HasNamedPolicy determines whether a named authorization rule exists.

(ptype string, params ...interface{})

Source from the content-addressed store, hash-verified

218
219// HasNamedPolicy determines whether a named authorization rule exists.
220func (e *Enforcer) HasNamedPolicy(ptype string, params ...interface{}) (bool, error) {
221 if strSlice, ok := params[0].([]string); len(params) == 1 && ok {
222 return e.model.HasPolicy("p", ptype, strSlice)
223 }
224
225 policy := make([]string, 0)
226 for _, param := range params {
227 policy = append(policy, param.(string))
228 }
229
230 return e.model.HasPolicy("p", ptype, policy)
231}
232
233// AddPolicy adds an authorization rule to the current policy.
234// If the rule already exists, the function returns false and the rule will not be added.

Callers 1

HasPolicyMethod · 0.95

Calls 1

HasPolicyMethod · 0.65

Tested by

no test coverage detected