@@ -34,20 +34,20 @@ MIDDLEWARE = [
3434``` python
3535import casbin
3636
37- def __init__ (self , get_response ):
38- self .get_response = get_response
39- # load the casbin model and policy from files.
40- # change the 2nd arg to use a database.
41- self .enforcer = casbin.Enforcer(" casbin_middleware/authz_model.conf" , " casbin_middleware/authz_policy.csv" )
42-
43- def check_permission (self , request ):
44- # change the user, path, method as you need.
45- user = request.user.username
46- if request.user.is_anonymous:
47- user = ' anonymous'
48- path = request.path
49- method = request.method
50- return self .enforcer.enforce(user, path, method)
37+ def __init__ (self , get_response ):
38+ self .get_response = get_response
39+ # load the casbin model and policy from files.
40+ # change the 2nd arg to use a database.
41+ self .enforcer = casbin.Enforcer(" casbin_middleware/authz_model.conf" , " casbin_middleware/authz_policy.csv" )
42+
43+ def check_permission (self , request ):
44+ # change the user, path, method as you need.
45+ user = request.user.username
46+ if request.user.is_anonymous:
47+ user = ' anonymous'
48+ path = request.path
49+ method = request.method
50+ return self .enforcer.enforce(user, path, method)
5151```
5252
5353- The default policy `` authz_policy.csv `` is:
0 commit comments