Answer the question
In order to leave comments, you need to log in
How to design an access control system for an application?
Briefly at first)
Good day!
I ask for help with the design / redesign of the access control system. Or choosing a ready-made one, choosing libraries, patterns, whatever.
Now in detail)
What is an
Application with a large number of connections between data, rest api written in nodejs using the loopback.io framework . The application is already in production, but is actively developing - new models, fields, connections are added weekly.
What you want
1) Allow user actions (reading, editing) according to the following criteria:
- belonging to the current user - example: the action occurs with the event model, it has a connection with the manager from the client side (contactFromCustomerId), if it is the current user, then this action is allowed to him.
- belonging to a different model to which the current user belongs - example: the action happens to the event model, the current user has an association with a company, the event has an association with a user who has an association with a company, if the companies are the same, the action is allowed.
- fields that are affected by the action - example: a user with this role is allowed to view only a part of the fields of the event, and update one in general.
- the state of the fields of the model to which the action is addressed - for example: an event for the current user can only be edited in the new status.
- the state of the associated model fields - example: the user can only update the fields of the estimate model if the event associated with the estimate has the new status.
The criteria can be layered on top of each other, for example, the user can edit only certain fields of the estimate model and only when the event belongs to his company and is in the new status.
Criteria can and will be new.
2) Allow users to create rights themselves, enable / disable existing permissions.
3) Create permissions that control the visibility of content - for example, manager0 working in the system should see information in window A, manager1 should see the same information in window B.
What was
Considered n number of libraries where access control systems are implemented.
Read about ACL.
We decided (perhaps erroneously) that none of the implementations suits us and we will write down our own within an acceptable (just erroneously) time frame.
What is/What has already been done with it
Permissions are handled in a separate library.
Permissions are only positive. (allow to do something)
Permission meta information is stored in configs, configs are located next to the file describing the model, example:
{
// ... ,
"event_create": {
"remoteMethod": [
"create",
"upsert"
],
"httpMethod": [
"post",
"put",
"patch"
],
"modelName": "Event",
"actionType": "write"
},
"event_read": {
"remoteMethod": [
"find",
"findOne",
"findById",
"exists",
"count",
"get"
],
"httpMethod": "get",
"modelName": "Event",
"actionType": "read"
},
// ...
}
{
"remoteMethod": "get"
"httpMethod": "get",
"modelName": "Event",
"actionType": "read"
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question