casbin / casbin-hub

The hub for Casbin
https://dashboard.casbin.com
Apache License 2.0
87 stars 46 forks source link

added syntax checks and validations of models #68

Closed techguybiswa closed 4 years ago

techguybiswa commented 4 years ago

Fixes : [61]

Description :

  1. Integrated CodeMirror in the Dashboard while writing the syntax for model. This was done to enhance UI/UX and also to support new line. Earlier new line was not parsable in the input box.
  2. Based on the docs https://casbin.org/docs/en/syntax-for-models several input validations are put in place: a. The model must have at least [request_definition], [policy_definition], [policy_effect], [matchers]. b. The policy_effect could be ONLY any of the 4 predefined models : some(where (p.eft == allow)) or !some(where (p.eft == deny)) or some(where (p.eft == allow)) && !some(where (p.eft == deny)) or priority(p.eft) || deny c. If the model is of type RBAC then role_definition is also mandatory.

--

Screenshot of changes :

<img src="https://i.ibb.co/tpXbtq7/Screenshot-2020-03-30-at-10-51-43-AM.png" />

Please ensure Checkmark the following :

[ YES] - Tested Localy [ NO] - Checked in IE11 and Firefox [ NO] - Checked in mobile [ NO] - Backend work [ YES] - Frontend work [ YES] - Bug Fixes [ YES] - Enhancements

techguybiswa commented 4 years ago

Hi @hsluoyz So are there any changes that I need to make in the PR to make it get accepted?

hsluoyz commented 4 years ago

Hi @techguybiswa

Can this be also used in our Casbin editor? https://github.com/casbin/casbin-editor

I think we can make a NPM package to be used by both Casbin editor and Casbin dashboard (this repo). They both use React. So I think this way works.

Can you first check the difference between your code and Casbin editor's validator, then merge its useful stuff, then develop and publish this new module?

I hope this module is UI un-opinionated, only do the validation work. Better to pass through all CodeMirror parameters. So users can still customize UI for their own "Casbin editor".

techguybiswa commented 4 years ago

Yeah so since the validation for models is being used in multiple repositories I definitely think that having a separate NPM package to validate the model will be a good idea.

So, for now, I will check the casbin-editor repository and merge the useful features of both the repositories and then publish it as an NPM package so that it can be used in both the repository.

nodece commented 4 years ago

Thank you for your contribution, this is good idea, the PR is too long, so I decided to close the PR. This feature will be migrated by @438561537.