Exposing permissions to frontend can be dangerous #594
HommeSauvage
started this conversation in
General
Replies: 2 comments
-
Depending on the use case and business model. First of all, In case api shares permissions, it should do this for a logged in user only. There are no risks in knowing what you can do as a user in a system but in case your API model is very different from frontend model or if you want to keep dependency on casl only in backend then Boolean flags is a way to go |
Beta Was this translation helpful? Give feedback.
0 replies
-
Keep in mind that permissions is about access to data not about access to ui sections |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Using something like
@casl/react
for the frontend can be tempting, as you won't have to write a lot of code to hide and show elements. However, I think this can be dangerous.Sending all the permissions JSON with a
user
object (or worse, defining them on the frontend) bears the risk of showing these permissions to a potential hacker who can then target users with elevated permissions to try and hack them to gain access.This would be more difficult if no permissions are displayed as this will make the hacker try to guess who's the user with elevated permissions.
So I think, it's better to keep all those permissions on the backend only and for the frontend, use simple permissions like:
These can be very high level and not specific to any subject, just general boolean values, then it's up to the backend to validate the abilities of the the user.
Beta Was this translation helpful? Give feedback.
All reactions