fix: policies need to be added after
This commit is contained in:
parent
212832eda1
commit
87ebf5012b
|
@ -18,15 +18,16 @@ func GetCasbin(logger *zap.Logger) *casbin.Enforcer {
|
||||||
|
|
||||||
a := NewPolicyAdapter(logger)
|
a := NewPolicyAdapter(logger)
|
||||||
|
|
||||||
_ = a.AddPolicy("admin", "/admin", []string{"GET"})
|
|
||||||
_ = a.AddPolicy("admin", "/admin", []string{"POST"})
|
|
||||||
_ = a.AddPolicy("admin", "/admin", []string{"DELETE"})
|
|
||||||
|
|
||||||
e, err := casbin.NewEnforcer(m, a)
|
e, err := casbin.NewEnforcer(m, a)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Fatal("Failed to create casbin enforcer", zap.Error(err))
|
logger.Fatal("Failed to create casbin enforcer", zap.Error(err))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add policies after creating the enforcer
|
||||||
|
_ = a.AddPolicy("admin", "/admin", []string{"GET"})
|
||||||
|
_ = a.AddPolicy("admin", "/admin", []string{"POST"})
|
||||||
|
_ = a.AddPolicy("admin", "/admin", []string{"DELETE"})
|
||||||
|
|
||||||
return e
|
return e
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue