Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose programmatic way of loading a model #2

Closed
kibertoad opened this issue Jan 9, 2021 · 4 comments · Fixed by #3
Closed

Expose programmatic way of loading a model #2

kibertoad opened this issue Jan 9, 2021 · 4 comments · Fixed by #3

Comments

@kibertoad
Copy link
Contributor

According to official documentation, it is possible to instantiate casbin model programmatically instead of loading it from file. See https://casbin.org/docs/en/model-storage#load-model-from-code

Would you be open to a PR that would implement support for the same in fastify-casbin?

@simoneb
Copy link
Member

simoneb commented Jan 9, 2021

This is already possible, the only issue is that the name of the option modelPath is kinda off, because in practice what you provide can be anything that newEnforcer supports as the first argument, including an instance of a casbin model initialized in code.

@kibertoad
Copy link
Contributor Author

@simoneb Types are wrong then. Can I submit a PR that would fix it then?

@simoneb
Copy link
Member

simoneb commented Jan 9, 2021

absolutely! you may want to rename the argument to model, too. it will require a semver major but it would be a more accurate name

@kibertoad
Copy link
Contributor Author

@simoneb Implemented it in backwards-compatible way, but if you prefer to only keep one param, can drop the modelPath and remove all the compatibility logic.

@simoneb simoneb closed this as completed in #3 Jan 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants