Permissions are everywhere and very important to secure your application from unauthorized actions and potential data loss.
A system to handle and ...
For further actions, you may consider blocking this person and/or reporting abuse
const naveen = DEFAULT + DEFAULT
Now I can enter LABORATORY
That's not quite how it works and how you should do it in your application but technically yes ππ₯
That's why you should use only bitwise OR when combining permissions instead of addition as you used in your example.
Now i get what you exactly mean. I was also thinking about this but now I realized.
I will edit this! Thanks
Yes, that's what I mean. You only said about adding permissions. For removing and toggling them you can use following operations
Awesome I'll paste that in the post π
Woah, nice. Never thought permissions would be managed using such low level concepts when high level plug n play abstractions are the way to go these days. I would like to see implementations like these in other areas as well.
Thank you a lot! In what areas would you prefer?
Not sure but I can give you a rough idea. When I was talking about low level concepts, I was talking about concepts included in OS design (drivers, interfaces, paging, separation of concerns by layering), computer architecture and programming language basics. Bitwise operators is one such topic that I think we only hear or learn about while studying computer science basics. But here its directly used to manage permissions in a very practical way and further on, you said that its ever more efficient due to its operating on a binary level.
By other areas, I can think of maybe plugging in security loopholes in applications (prevention of various injection attacks maybe) and optimization techniques for both space and time. I got a gut feeling that preventing injection attacks requires us to validate user input or user supplied data on the server and so maybe that is where we might be able to plug in bitwise operators to do things more efficiently.
Now I get what you meant. I can only agree with that! π₯
Nice job and excellent idea! Thanks a lot.
The idea is actually a very old one. For example, this is exactly how NTFS permissions work.
That's correct. But even if it's old it's still very useful. It's also very fast. If you get deeper into it you begin to love the simplicity and scalability.
Thank you very much! π
Interesting! I've heard of bitfields, are those similar?
I've looked into bit fields and it says
A bit field is a data structure that consists of one or more adjacent bits
. So it seems like yes those are familiar and in my understand a bit field is in this example eitherDEFAULT
orLABORATORY
but alsothem combined e.g.
Jenny
is a bit field. π₯If someone knows more specific about this feel free to correct me π.
Du bist Meine Rettung! DAS war das was ich unbedingt gebraucht habe!!!!!!
Vielen Dank fΓΌr das tolle Tutorial
It's a pleasure! I wish you much succes! And happy coding π
I built something similar. However, it was for storing days of weeks. It aims to reduce data size on large datasets. Say, a booking system with millions of records.
npmjs.com/package/daystobits
Great job explaining how it works! Kudos!
Very nice! π₯