Hi I am trying to create a role based dynamic route authorization system on my NodeJS ExpressJS powered API server.
There will be some roles like Admin, StandardUser etc. and they can't be edited or removed.
More roles can be added by authorized users dynamically. These roles of course can be edited or removed.
Authorized users can set all the route permissions. They can set Role A can use Route X. They can do it for all kind of roles. Dynamic roles or "unchangeable" roles like Admin and StandardUser.
Now my scenario shows that I need a Roles Table because of my dynamic roles and a RoutePermissions Table for dynamically assign route access to my roles. However I can't find a way to store my "unchangeable" data.
Where should I put my "unchangeable" (I don't know if there is a term for it. Please let me know.) role data. Where should I put SuperAdmin and StandardUser roles? Because if I put them in roles table in my DB I will have 2 unchangeable rows in it my dynamic data table.
Where should I put my "unchangeable" route data. Since the routes (POST /users/deactivate) are coded in the system I don't think it is correct to put them in database. Because I think, the database should contain only the dynamic data but my routes are not dynamic.
If i don't put my "unchangeable" data to DB. I can store it in my code like enums or consts but how can I dynamically create permissions with them? Because permissions are dynamic for each role. (Even for Admin and StandardUser remember they are not dynamic roles.)