3

What is the recommended option to design a privilege system?

My application has some users with several roles(Admin, consulting, expert, reporter..) Each role has some privileges (read document, write document, send mail, read mail, write mail, read book, write book...).

Is a unique privilege must give access to only a unique functionnality? Is Write include Read privilege or is a user must have read and write privilege to actually write

1

1 Answer 1

4

"Does Write include Read"...

This question can be divided into two parts.

Domain Design

Your stakeholders need to decide the externally visible privileges from the domain and business perspective. These are the privileges that your customers will see, and those that your support staff will speak with customers about. These are domain and business decisions, not programmer decisions.

(The business may choose that Write implies also Read -- though there are valid cases where that isn't necessarily true).

Internal Implementation

The programmers implementing the system need to decide the granularity of the privileges they want to see and test against within the code. This may very well separate out Read from Write even if the business chooses that regarding the externally articulated privileges Write includes Read.

What we want to do is cleanly map the business notion of privilege to the internal representation, in particular, so that this is DRY (occurs in only one place in the source code). This so we don't bake in assumption that Write includes Read in various places scattered within the implementation.

1
  • On write not implying read: imagine a system where users can flag comments. They can't see all the flagged posts, so essentially they have create permissions but not read. Dec 15, 2016 at 1:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.