MSBA-341 · Lesson 10 of 12 · 18 min
Security objects
▶ Video coming soon A video version of this lesson is on the way.
By now the inspection feature had new fields, a status enum, a certificate table, a waiver workflow, an alert job and a report. Every one of them was invisible to users who had no security access to it, and some of them, such as waiving a certificate, had to be restricted to the right people. Thandeka's audit requirement was blunt: a receiving clerk must never be able to approve their own waiver, and the auditors must be able to see who could do what. Desmond told Prudence that security in finance and operations apps is designed by developers as metadata and assigned by administrators, so the developer's job was to build the right security objects, at the right granularity, with names an auditor could understand.
The security model
Security is role-based. Users are assigned roles. Roles contain duties, and duties contain privileges. Privileges grant permissions on entry points, such as menu items, data entities, service operations and form controls, and through those on the tables and fields the entry points use. Roles can also contain privileges directly, and roles can contain sub-roles. The model separates what a person is (role), what business tasks they perform (duty) and what specific access each task needs (privilege).
| Object | Created by | Contains | Example |
|---|---|---|---|
| Role | Developer or administrator | Duties, privileges, sub-roles | CR Quality engineer |
| Duty | Developer or administrator | Privileges | CR Approve inspection waivers |
| Privilege | Developer or administrator | Permissions on entry points | CRInspWaiverApprove |
| Entry point | Developer | The menu item, entity or service operation being secured | Action menu item CRInspWaiverApprove |
| Permission | Set on the privilege | Access level: Read, Update, Create, Correct, Delete | Delete on the approve action |
Administrators can create and change roles, duties and privileges in the security configuration pages of the client, and those changes are stored as data. Developers create them as metadata in Visual Studio, which is the right choice for objects that belong with a feature and must be deployed with it. Cobalt Ridge's rule was that security for a custom feature was built in the CobaltRidgeCustom model, so it went through source control, review and the same deployment as the code it protected.
Privileges and entry points
Every entry point that users can reach needs to be in at least one privilege, or nobody except a system administrator can use it. For the inspection feature, Prudence listed the entry points first: the display menu item for the certificate form, the action menu items for submitting and approving a waiver, the output menu item for the weekly report, the menu item for the alert job's dialog, and the data entity for certificates. She then designed privileges around tasks rather than around objects. Viewing certificates and maintaining them were separate privileges, because auditors should see but not change.
Each permission on an entry point has an access level. Read lets the user open and view; Update allows edits; Create allows new records; Correct allows corrections to date-effective data; Delete allows deletion and, for action menu items, is often the level that lets the action run. The access level on the entry point is applied to the tables the entry point uses, through permission sets that the framework derives from the form's data sources. A privilege granting Read on the certificate form lets the user see certificate records but not change them.
| Privilege | Entry points and access |
|---|---|
| CRInspCertView | CRInspCertTable display menu item: Read; CRInspectionCertificateEntity: Read |
| CRInspCertMaintain | CRInspCertTable display menu item: Delete; CRInspectionCertificateEntity: Delete |
| CRInspWaiverRequest | Waiver request form: Create; submit action menu item: Delete |
| CRInspWaiverApprove | Approve action through the workflow; waiver request form: Read |
| CRInspAlertRun | Alert job action menu item: Delete |
| CRCastingCertReportView | CRCastingCertReport output menu item: Read |
Duties and roles
Duties group privileges into business responsibilities. Prudence created four: CR Maintain inspection certificates, CR Request inspection waivers, CR Approve inspection waivers, and CR Monitor inspection compliance, which combined the view privilege with the report. Duties are where separation of duties is expressed, because conflict rules are defined between duties.
For roles, Desmond's advice was to extend standard roles where possible instead of creating new ones. Cobalt Ridge's buyers already had the standard purchasing agent role, so a role extension added the request and monitor duties to it. Quality engineers had no standard equivalent, so a new role, CR Quality engineer, held the maintain and approve duties. The warehouse receiving clerk role was extended with the request duty, which is how clerks could ask for a waiver when a certificate was late.
Extending security objects
Roles and duties can be extended: an extension can add duties and privileges to a role and privileges to a duty. Privileges can also be extended to add entry points. This matters when a standard form gains a new control or a standard menu item needs to be in a custom duty. For new fields on standard forms, there is usually nothing to do, because the field inherits the form's security through its table. The exception is a field that should be more restricted than the rest of the form, which is handled with a field-level permission or by securing a control.
Prudence used one privilege extension. The standard privilege that granted access to the purchase order form was used by many roles, and the new CRHeatNumber column should be visible to all of them, so no change was needed. However, the new menu item that opened the certificate from the purchase line had to be added somewhere, and putting it in a standard privilege would have given it to everyone with that privilege. She put it in CRInspCertView and added that privilege to the right duties instead.
Segregation of duties
Segregation of duties rules identify pairs of duties that one user should not hold. An administrator defines a rule, for example that CR Request inspection waivers conflicts with CR Approve inspection waivers, and the system then checks role assignments. When a user would receive conflicting duties, the assignment is flagged, and an administrator must either resolve it or record an override with a reason. Existing assignments can be checked for conflicts that predate the rule.
Thandeka's requirement that a clerk could not approve their own waiver was met at two levels. The segregation rule prevented the same user from holding both duties without an override. And the workflow configuration assigned approvals to the quality engineer role, so even a user who somehow held both duties would not be assigned their own request if the workflow's conflict setting was turned on. Desmond pointed out that the security design should not rely on one of these alone.
Extensible data security
Roles and privileges decide which features a user can use. Sometimes access to records within a feature must also be restricted, such as limiting a plant's quality engineers to certificates for their own plant's receipts. Extensible data security policies, often called XDS policies, add a filter to every query on a constrained table for users in specified roles. A policy names a primary table and a query that defines the allowed records, a set of constrained tables, and the roles it applies to. Cobalt Ridge decided not to use XDS for certificates, because quality engineers sometimes covered for other plants, but Desmond walked through an example so Prudence would recognize the pattern on the exam.
XDS has real costs. Every query on a constrained table becomes more complex, which can affect performance, and a badly designed policy can hide data users need or produce errors in batch jobs that run as a user covered by the policy. Desmond's guidance was to use XDS only for clear requirements, keep the policy query simple and indexed, and test with each affected role.
Securing code and services
Some security checks belong in code. When a service operation or a class method performs a sensitive action, it can check whether the user has access to a menu item or a privilege before proceeding, which protects the action even if it is called from a path the menu structure did not anticipate. Data entities exposed through OData are secured by privileges on the entity, so CRInspectionCertificateEntity had its own Read and Delete permissions in the view and maintain privileges. Custom services have service operations that must be added to privileges as entry points.
Reviewing security
Administrators can see the effect of the security design through the security diagnostics for a form, which list the roles, duties and privileges that grant access to it, and through reports that show users and their roles. Prudence ran the security diagnostics on the certificate form to confirm that only the expected roles had access, logged in as a test user with only the receiving clerk role to confirm that the approve button did not appear, and gave Thandeka a document listing each new role, duty and privilege with its purpose. That list became part of the release notes, which made the audit review straightforward.
Least privilege in practice
The principle of least privilege says each user should have only the access their job needs. In practice that means privileges built around tasks, duties that match business responsibilities, and roles that match jobs, with nothing extra added because it is convenient. Prudence's first draft of CRInspCertMaintain granted Delete on the certificate entity, which would have let a quality engineer delete certificates through Excel. Thandeka asked why anyone needed to delete a certificate. The answer was nobody did, so the access level was reduced to Update, and a separate, unassigned privilege with Delete was kept for the rare case of correcting an error under the controller's supervision.
Licensing and security
Security design also affects licensing. Menu items carry properties that state the license type their use requires, and finance and operations apps include reports that estimate users' license needs from their roles. Adding a maintain-level entry point to a role that light users hold can change the license those users need. Desmond asked Prudence to run the license reports in the sandbox after the security changes and compare them with the numbers before, so that Thandeka would not discover a licensing change at renewal time. Microsoft's licensing rules change from time to time, so the team used the reports in the current version rather than relying on memory.
Testing security
Testing security means logging in, or impersonating where the environment allows, as users who hold only the roles being tested. Prudence created test users with exactly one role each: the extended purchasing agent, the extended receiving clerk and the new quality engineer. With each, she ran through the inspection feature and recorded what each could see and do. A short table in the test script compared the expected and actual access for each entry point, and the table became part of the evidence Thandeka gave the auditors.
Desmond closed by pointing out that security objects are code like any other part of the feature. They are reviewed in pull requests, deployed in packages, listed in release notes and tested in user acceptance testing. The difference is that a mistake in security can go unnoticed for longer than a mistake in logic, because a user with too much access rarely complains, which is why the audit evidence mattered as much as the design.
Worked problem
A missing button
After deployment to the test environment, a quality engineer reports that the Approve button for waivers does not appear, although the approve duty is in their role. What should Prudence check?
Show solution
- Open the security diagnostics for the waiver form and see whether the approve action is granted by any of the user's roles.
- Check that the CRInspWaiverApprove privilege contains the approve action menu item with an access level that lets the action run.
- Check that the duty containing the privilege is in the role that is assigned to the user in that legal entity; role assignments can be limited by organization.
- Check the workflow configuration: the approval step must assign work to this user or role, or the button will not show for this document.
Answer: Missing actions are usually a privilege that lacks the entry point or access level, a role assigned in a different company, or a workflow assignment that does not include the user.
Common mistakes
MistakeAdding custom entry points to a standard privilege that many roles share.
InsteadCreate a custom privilege and add it to the duties and roles that need it.
MistakeCreating a new role for every custom feature.
InsteadExtend standard roles where users already have them; create roles only for new responsibilities.
MistakeRelying only on workflow assignments to separate requesters from approvers.
InsteadAdd a segregation of duties rule as well.
MistakeUsing XDS policies for loose preferences.
InsteadUse XDS only for clear record-level requirements, with simple, indexed policy queries.
Summary and key terms
- Security is role-based: roles contain duties, duties contain privileges, and privileges grant permissions on entry points.
- Access levels on entry points flow to the tables the entry points use.
- Developers build security for features as metadata in the model so it is reviewed and deployed with the code.
- Roles, duties and privileges can be extended; extend standard roles where possible.
- Segregation of duties rules flag conflicting duties; XDS policies restrict records within a feature.
- Role
- A set of duties and privileges that matches a job.
- Duty
- A group of privileges for a business responsibility.
- Privilege
- A set of permissions on entry points.
- Entry point
- A menu item, data entity, service operation or other object users reach the system through.
- Extensible data security (XDS)
- Policies that filter records for users in given roles.
Practice problems
Work each problem on paper first, then reveal the answer to check.
Why were viewing and maintaining certificates separate privileges?
Show answer
Auditors need to see certificates without being able to change them.
How did receiving clerks gain the ability to request waivers?
Show answer
A role extension added the CR Request inspection waivers duty to the standard receiving clerk role.
Why did Cobalt Ridge decide against an XDS policy on certificates?
Show answer
Quality engineers sometimes cover other plants, and XDS adds query cost and risk.
Lesson quiz · 5 questions
Score 60% or more to complete this lesson.
Create a free account to save your progress, take quizzes and earn a certificate.