CasbinService 添加 reload
重载 casbin policy
This commit is contained in:
parent
45df167315
commit
37598e44fc
@ -88,4 +88,11 @@ public class TestController {
|
||||
@RequestParam String method) {
|
||||
return JsonResponse.success(casbinService.enforce(identify, system, url, method));
|
||||
}
|
||||
|
||||
@PostJson("/casbin")
|
||||
@Operation(summary = "重新加载 casbin policy")
|
||||
public JsonResponse<Void> reloadCasbin(){
|
||||
casbinService.reload();
|
||||
return JsonResponse.success(null);
|
||||
}
|
||||
}
|
||||
|
@ -36,4 +36,6 @@ public interface CasbinService {
|
||||
List<String> getRelationForRoleInSystem(String role, String system);
|
||||
|
||||
boolean delRole(String role, String system);
|
||||
|
||||
void reload();
|
||||
}
|
||||
|
@ -89,4 +89,9 @@ public class CasbinServiceImpl implements CasbinService {
|
||||
enforcer.removeFilteredNamedPolicy("p", 0, Permission.Identify.getRoleName(Permission.Identify.ROLE, role), system);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reload() {
|
||||
enforcer.loadPolicy();
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,9 @@ package cn.skcks.matrix.v2;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
|
||||
@Lazy
|
||||
@SpringBootApplication(exclude= DataSourceAutoConfiguration.class)
|
||||
public class Application {
|
||||
public static void main(String[] args) {
|
||||
|
@ -50,5 +50,5 @@
|
||||
</root>
|
||||
|
||||
<logger name="cn.skcks.matrix.v2.config" level="DEBUG" />
|
||||
<logger name="cn.skcks.matrix.v2.utils.redis" level="DEBUG" />
|
||||
<logger name="cn.skcks.matrix.v2.utils.redis.RedisUtil" level="DEBUG" />
|
||||
</configuration>
|
||||
|
Loading…
Reference in New Issue
Block a user