A simple implementation of casbin/casbin with a database
The database schema which contains the users, routes and roles tables.
The database data : the fixtures for this example
The roles have access to the routes and we give these roles to a user.
The roles can have multiple roles to inherit their rights.
The users can have multiple roles.
Casbin library execute the method LoadPolicy in the Pgsql Casbin Adapter
- docker
- docker-compose
docker-compose upGET
#OK
curl http://localhost:8081/people -H "AUTH_IDENTITY:Sadmin"
curl http://localhost:8081/people -H "AUTH_IDENTITY:Liliread"
#NOK
curl http://localhost:8081/people -H "AUTH_IDENTITY:Moderator"POST
#OK
curl -X POST http://localhost:8081/people -H "AUTH_IDENTITY:Sadmin"
#NOK
curl -X POST http://localhost:8081/people -H "AUTH_IDENTITY:Liliread"
curl -X POST http://localhost:8081/people -H "AUTH_IDENTITY:Moderator"PUT
#OK
curl -X PUT http://localhost:8081/people/1 -H "AUTH_IDENTITY:Sadmin"
#NOK
curl -X PUT http://localhost:8081/people/1 -H "AUTH_IDENTITY:Liliread"
curl -X PUT http://localhost:8081/people/1 -H "AUTH_IDENTITY:Moderator"DELETE
#OK
curl -X DELETE http://localhost:8081/people/1 -H "AUTH_IDENTITY:Sadmin"
curl -X DELETE http://localhost:8081/people/1 -H "AUTH_IDENTITY:Moderator"
#NOK
curl -X DELETE http://localhost:8081/people/1 -H "AUTH_IDENTITY:Liliread"