Comments (6)
from casbin-spring-boot-starter.
@tunctolgahan hi, can you run this example: https://github.com/jcasbin/casbin-spring-boot-example (which uses this casbin-spring-boot-starter)? Does it work?
Did you use another Jedis version in your own project?
from casbin-spring-boot-starter.
Hi, thanks for your reply. I am a bit busy this week, check it ASAP and let you know.
For your Jedis version question, yes I use more up-to-date version of it in my own project.
from casbin-spring-boot-starter.
Hi again,
First, I checked the jedis version I use in my own project, it is 4.3.1. And my own project use maven, not gradle.
Second, the example project ran well. I checked all the endpoints defined in it, all returned HTTP 200.
After everything seems OK, I enabled both enableWatcher and use-synced-enforcer. Also I configured spring redis dependency manually (as described in readme file of this repo).
casbin:
storeType: file
enableWatcher: true
use-synced-enforcer: true
spring:
redis:
database: 0
host: localhost
port: 6379
Then, I created my own endpoints (in DataController) that adds a new policy to casbin db, and returning all policies:
@Secured("ROLE_ADMIN")
@PostMapping("/admins/add-policy")
public ResponseEntity<Data> addPolicy(Authentication authentication) {
logger.info("addPolicy called");
List<String> policy = new ArrayList<>();
policy.add("p");
policy.add("ROLE_ADMIN");
policy.add("/data/admins/add-policy");
policy.add("*");
enforcer.addPolicy(policy);
return ResponseEntity.ok().build();
}
@Secured("ROLE_ADMIN")
@GetMapping("/admins/get-all-policies")
public ResponseEntity<List<List<String>>> getAllPolicies(Authentication authentication) {
logger.info("getAllPolicies called");
List<List<String>> policies = enforcer.getPolicy();
return ResponseEntity.ok().body(policies);
}
When I called /add-policy and /get-all-policies endpoints from postman, I got this log output.
Please see the highlighted line "Method not implemented". Why I got this message? I think this is not something about watcher or synced-enforcer configure, because when I disabled both of them I got the same message after calling /add-policy.
org.casbin.jcasbin : Request: [admin, /data/admins/add-policy, POST] ---> true
org.casbin.jcasbin : Hit Policy: [ROLE_ADMIN, /data/admins/*, *]
org.casbin.config.CasbinFilter : session is authorized: B11F208EC2077C80DABBC800DBAAA4F4 admin POST /data/admins/add-policy
org.casbin.controller.DataController : addPolicy called
org.casbin.jcasbin : ****Method not implemented****
org.casbin.jcasbin : Request: [admin, /data/admins/get-all-policies, GET] ---> true
org.casbin.jcasbin : Hit Policy: [ROLE_ADMIN, /data/admins/*, *]
org.casbin.config.CasbinFilter : session is authorized: B11F208EC2077C80DABBC800DBAAA4F4 admin GET /data/admins/get-all-policies
org.casbin.controller.DataController : getAllPolicies called
Also, /admins/get-all-policies returned the all policies as expected (the last policy is the policy I added via endpoint):
[
[
"ROLE_USER",
"/data/users/*",
"*"
],
[
"ROLE_ADMIN",
"/data/users/*",
"*"
],
[
"ROLE_ADMIN",
"/data/admins/*",
"*"
],
**[
"p",
"ROLE_ADMIN",
"/data/admins/add-policy",
"*"
]**
]
I think there is something wrong with redis/watcher structure on this example project too. Because on redis server, when I checked the "connected client list", I don't see any.
from casbin-spring-boot-starter.
Yes, it's seems jedis-client version is incompatible with the Spring Data Redis, Compatible versions are available here, you can switch to you version to see
try downgraded or upgraded version, or try use the default client in spring-boot-data-redis.
Does example invalid? Did you manually introduce the dependency?
from casbin-spring-boot-starter.
Closed as resolved
from casbin-spring-boot-starter.
Related Issues (20)
- JDBC Adapter for PostgreSQL fails for creation of Table HOT 12
- DB2Adapter can not work after adding id for the casbin_rule table HOT 2
- JDBCAdapter only support fixed table name HOT 3
- JdbcAdapter will not load the policy from database in initial phase HOT 4
- The built-in Watcher doesn't support customized Redis channel, how to use the official Java's Redis-Watcher? HOT 5
- Replace jacsbin 1.9.2 in casbin-spring-boot-starter with version 1.21.0 HOT 4
- Support for policy subset loading HOT 2
- Fix CI error HOT 2
- H2 2.0.202 seems not work with default jdbcadapter HOT 3
- Replace built-in adapter and watcher with official jdbc-adapter and redis-watcher HOT 7
- WARNING: Illegal reflective access by org.springframework.cglib.core.ReflectUtils HOT 5
- 0.5.0 version cannot find Enforcer to inject HOT 1
- feature support for springboot3.0 HOT 1
- Casbin Starter Can't Use Dynamic Data Source HOT 3
- Release Casbin SpringBoot Starter v1.0.0 HOT 2
- [feature] Update dependencies to resolve Maven alerts HOT 2
- RedisWatcherAutoConfigration bug HOT 3
- unable to refresh roles for user HOT 3
- Could you add JDK information to the docs? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from casbin-spring-boot-starter.