Closed ghaiklor closed 5 years ago
Hi @ghaiklor In fact, already did that even before you ask, see: https://github.com/casbin/node-casbin#policy-persistence
I saw lots of tests and docs. It's really a high-quality implementation, I also learnt something from it :) BTW, you can also add some badges, including Travis CI and code coverage, also the NPM version. Then it would be better.
Thanks for the contribution indeed!
Wow, that is a really fast response, thank you 🙏 Yeah, I thought about badges, did not have time for this yet.
Regard to tests, there are not much tests. Just simple smoke tests that check that when you are modifying policy, changes reflects in MongoDB.
@ghaiklor I think I can help. I have sent a PR here: https://github.com/elasticio/casbin-mongoose-adapter/pull/1. Can you switch on the following services? So the badges will work.
Thanks for merging the PR. This issue can be closed now :)
@hsluoyz thanks, merged the PR.
We are using CircleCI instead of Travis, so I've updated the badge to grep status from CircleCI. Regard to coveralls, it is not integrated from our side, so there are no information (no sense for doing that).
I'll add the badge from coveralls once it will be enabled for the repo.
@ghaiklor , Coveralls is free for open-source projects and I use it a lot. You can enable the repo in: https://coveralls.io/ if needed :)
@ghaiklor is there a reason for the additional layer of methods? e.g. using addPermissionForUser
instead of addPolicy
?
The latter seems to work just fine and in real time.
@Slind14 I think, this kind of questions better to ask @hsluoyz
AFAIU, addPermissionForUser
is the public method which handles not only the policies but the RBAC relations as well.
When addPolicy
is just an internal method for writing policies into the backend and ideally should not be used.
@Slind14 ghaiklor's answer is not wrong. They belong to RBAC API and Management API respectively. You can find the info here:
https://casbin.org/docs/en/management-api https://casbin.org/docs/en/rbac-api
would this let me create update and delete casbin policies into a mongodb document?
Hi @federicosan , if you have questions about this adapter, please raise an issue at: https://github.com/elasticio/casbin-mongoose-adapter
As promised, we have published our mongoose adapter for casbin that we are using in production at the moment.
Feel free to review it and if everything is ok, hoping to add it as official recommended adapter in README for node-casbin.
https://github.com/elasticio/casbin-mongoose-adapter
P.S. I made it thanks to your MongoDB adapter written in Go, so basically, this one is just a port from Go to NodeJS.