English | 中文
Currently not published to maven, please download the jar package to use
- Download model_request.conf put into
classpath:casbin/model_request.conf
- Just add the
@RequiresCasbin
annotation to the controller method, and the request will verify the request address permissions. The three elements here are: Shiro'sprincipals
value, requested path addressServletPath
, requested method typemethod
@RequiresCasbin @GetMapping public List<Menu> getRoot() { return menuService.getRoot(); }
- Assigning permissions to the request interface
CasbinSubject subject = (CasbinSubject) SecurityUtils.getSubject(); Enforcer enforcer = subject.getEnforcer(); // get enforcer String path = "/menu/root"; String method = "GET"; enforcer.addPermissionForUser(role, path, method); // Of course, according to the principle of rbac, the first parameter can be role or user enforcer.addRoleForUser(user, role); // Assign role to user
The following values are default values
shiro-jcasbin:
enabled: true // Enabled jcasbin
model: classpath:casbin/model_request.conf // madel path
rule-table: casbin_rule_request // policy table name
watcher: true // Enabled watcher,Need jetcd support
watcher-key: /casbin/watcher_request // Key name used by watcher