Welcome Guest, Not a member yet? Register   Sign In
Permission Handling Library
#1

Hi all! Hopefully you've seen my other libraries thread, so you know the routine. This one is a little different, in that the original library was a dual authentication/authorization library but both of these realms have changed so drastically since CI3 neither would work well as a direct "port". There are also other libraries in the works to be robust and comprehensive solutions (see for example @kilishan's Myth:Auth) so I haven't been sure if I will rework the original library at all.
That said, one of my favorite aspects of the original library was object permissions - think Unix "chmod" permissions for your models & instances. This library couples traditional named permissions with a CI4 take on object permissions. So, I give you:

Tatter/Permits - out-of-the-box permission handling for CodeIgniter 4

Basic usage:

1. Install with Composer: `> composer require tatter/permits`
2. Update the database: `> php spark migrate:latest -all`
3. Extend your models: `class JobModel extends Tatter\Permits\Models\PModel;`
4. Ready to use! `if ($jobs->mayCreate()) ...`
5. (Optional) Add overrides: `> php spark permits:add` or `> php spark permits:add deleteJobs groups 7`


This library is much more involved than the previous libraries, and has more room to grow. I am eager for feedback, suggestions, and contributions - feel free to respond here or on GitHub (https://github.com/tattersoftware/codeigniter4-permits).
Thanks for reading!
Reply
#2

[quote pid="363029" dateline="1554233786"]
Hi MGatner!

I have spent all my day integrating your library into my CI4 project. I managed to install your library and also successfully used the mayCreate, mayUpdate methods, etc. Everything seems to work perfect!

I only need one thing to finish integrating your library into my project: knowing exactly how the octal mode works to assign permissions.

Unfortunately the documentation you provide on your Github is short and not very detailed, so I have not been able to understand how exactly to assign permissions using the chmod-style four-digit octal mode. The only thing that is more or less clear to me is that the 1st digit is responsible for granting permission to create a record. The other digits are quite obscure.

I have managed to identify the octal mode for several combinations of permissions, although obviously I'm missing many:

  1. 00000. No privilege
  2. 07777. create, read, update, delete, list
  3. 02007. create, read, update, delete
  4. 07772. create, update, delete, list
  5. 04007. read, update, delete, list
  6. 02222. create, update, delete
  7. 04222. update, delete, list
  8. 00777. read, update, delete
  9. 07774. create, read, list
  10. 00002. update, delete
  11. 02224. create, read
  12. 07000. create, list
  13. 04444. read, list
  14. 02000. create
  15. 00004. read
  16. 04000. list

I admit that I have managed to identify these octal combinations without knowing what I am doing. I've done it blindly, simply swapping one number for another.

Could you please extend your documentation on this, explaining in more detail how to assign one permission or another, or various combinations of them?

I am sure that you have used your library in some of your projects. It would be very helpful to the community if you could upload to your Github a practical and complete examples of how you have integrated your library. Could we see a model and a controller for any of your projects using your library in octal mode, and maybe a SQL dump of the database?

I think your library is great and powerful, my God, and I think it absolutely deserves that we talk about its documentation and extend it for the good of all.

Thank you very much!
[/quote]
Reply
#3

For anyone else on this thread I responded on the GitHub issue: https://github.com/tattersoftware/codeig.../issues/15
Reply




Theme © iAndrew 2016 - Forum software by © MyBB