MSBA-343 · Lesson 1 of 12 · 21 min

Role-based security for developers

▶ Video coming soon A video version of this lesson is on the way.

The pump warranty module was live in CONFIG and the inspection certificate feature had passed its demo, but Kiri Langford's go-live checklist still had six open lines under the heading Developer hardening. Security sign-off from Thandeka. A performance baseline. Automated regression tests. A repeatable build and release pipeline. A plan for service updates. Monitoring in production. Desmond Oyediran-Platt booked a third series of clinics with Prudence Okolo to close them, one topic per session, and he started with security because every other item depended on it. A slow form can be tuned after go-live; a user who can void warranties they should only read is an audit finding on the first day.

Prudence had already built a privilege, a duty and a role extension in the earlier clinics. This session went underneath them. Desmond wanted her to understand what the security model actually checks at run time, which of its parts belong in code and which belong to administrators, and how a developer's choices show up later in license counts and segregation of duties reviews.

Why security is a developer's job

In finance and operations apps, nothing a user can open is secured by default from the user's point of view: every menu item, every service operation and every data entity is an entry point, and an entry point that no privilege grants is simply unreachable for anyone except a system administrator. That sounds safe, and it is, but it means that every feature a developer builds is useless to real users until the developer also builds the security objects that grant it. If the developer forgets, an administrator in a hurry tends to fix the problem by giving people a broader standard role, and the result is far more access than anyone intended.

Desmond's rule for Cobalt Ridge was that no pull request adding an entry point could be merged without the privilege that grants it. The build check could not enforce this on its own, so it became a line on the pull request template that the reviewer ticked: new menu items, new service operations and new data entities each listed with the privilege that covers them.

The four layers

Security in finance and operations apps is role-based and layered. At the bottom are permissions, which say what kind of access is granted to a securable object: Read, Update, Create, Correct or Delete for data, and Invoke for actions and service operations. Permissions are grouped into privileges, and a privilege is the smallest object that an administrator can assign. Privileges are grouped into duties, which describe a responsibility in business terms, such as maintaining pump warranties. Duties and privileges are grouped into roles, and roles are what users are assigned. The standard application also groups duties into process cycles, which help administrators browse duties by business process but do not grant anything themselves.

Four stacked layers. A role such as Service desk agent contains duties such as Maintain pump warranties. Duties contain privileges such as Maintain pump warranty records. Privileges contain permissions on entry points such as the CRPumpWarrantyTable display menu item with access level Delete, and on tables reached through the form.
Roles hold duties, duties hold privileges, and privileges hold permissions on entry points.

A permission on an entry point carries an access level. For a display menu item, the access level decides what the user can do on the form it opens: Read lets them view, Update lets them change existing records, Create lets them add records, Correct is used for date-effective data, and Delete includes everything below it. Action and output menu items use Invoke. The form's data sources then inherit what the entry point allows, so a developer rarely has to list every table a form touches. The framework infers table permissions from the form's metadata when the privilege is built.

The security layers with objects from the pump warranty module.
LayerWhat it representsCobalt Ridge example
RoleA job that a person doesCR Quality engineer; Service desk agent extended by CobaltRidgeCustom
DutyA responsibility in business termsCR Maintain pump warranties; CR Inquire into pump warranties
PrivilegeAccess needed for one taskCRPumpWarrantyTableMaintain; CRPumpWarrantyTableView; CRPumpWarrantyVoid
PermissionAccess level on one securable objectCRPumpWarrantyTable display menu item, Delete; CRPumpWarrantyVoid action menu item, Invoke

Designing privileges for a feature

Prudence's first warranty privilege had granted Delete on the warranty form. Desmond asked her to split it. A good privilege set for a feature usually has at least two levels, one to view and one to maintain, and a separate privilege for each sensitive action. The warranty module ended with three: CRPumpWarrantyTableView, which grants Read on the display menu item; CRPumpWarrantyTableMaintain, which grants Delete on the same menu item; and CRPumpWarrantyVoid, which grants Invoke on the action menu item that voids a warranty. The certificate output menu item was added to the view privilege, because anyone who can see a warranty can reprint its certificate.

The split mattered because the people involved had different jobs. Customer service agents in both companies needed to look up a serial number while a customer was on the phone. Only the warranty administrator in each company should change warranty terms. Voiding a warranty, which removes the company's obligation to repair a pump, was something Thandeka wanted limited to two people and reviewed every quarter.

A summary of the three warranty privileges as they appear in the element designer. In Visual Studio each one is an XML element in the CobaltRidgeCustom model.
Privilege: CRPumpWarrantyTableView
  Label: @CRCustom:ViewPumpWarranties
  Entry points:
    CRPumpWarrantyTable (MenuItemDisplay)    Access level: Read
    CRPumpWarrantyCertificate (MenuItemOutput) Access level: Invoke

Privilege: CRPumpWarrantyTableMaintain
  Label: @CRCustom:MaintainPumpWarranties
  Entry points:
    CRPumpWarrantyTable (MenuItemDisplay)    Access level: Delete

Privilege: CRPumpWarrantyVoid
  Label: @CRCustom:VoidPumpWarranties
  Entry points:
    CRPumpWarrantyVoid (MenuItemAction)      Access level: Invoke

Prudence noticed that a privilege does not say which legal entity it applies to. Desmond explained that company scope is decided when a role is assigned, not when it is designed. An administrator can assign a role to a user for all legal entities or only for specific organizations, which is how Cobalt Ridge would limit the warranty administrator in CRUS to CRUS records without any extra code.

Other securable objects

Menu items are the most common entry points, but they are not the only ones. Service operations exposed through custom services are secured as entry points with Invoke access, and a developer who adds a service for the plant quality system must also add a privilege for it, or the integration user will be refused. Data entities have their own permissions: a privilege can grant access to an entity for use through OData and the data management framework, separately from the forms that show the same data. MSBA-342 covers those integration paths, and the rule is the same there: the integration user gets a narrow role that grants exactly the entities and services the integration calls.

Two finer controls are worth knowing. Tables can be protected by the table permissions framework: a table whose AOS authorization property is set requires that the user has explicit permission on the table itself, even when they reach it through code, which is useful for highly sensitive data. Individual form controls can also be secured, so that a button or field on an otherwise accessible form needs a further permission. Desmond used neither for warranties. Both add maintenance, and he kept them for cases where an entry point alone cannot express the rule.

Duties, roles and role extensions

Duties are where security starts to read like the business. Desmond wrote duty names in the form a controller would use in a review: CR Maintain pump warranties, CR Inquire into pump warranties, CR Void pump warranties. Each duty held one or more privileges. Roles then received duties, not privileges, wherever possible. A role made of duties is easier for Thandeka to review, and it is the level at which segregation of duties rules are written.

For standard roles, a developer has two choices. A role extension adds duties or privileges to a standard role from the CobaltRidgeCustom model, without changing Microsoft's role definition. A new role is a separate object owned by Cobalt Ridge. Desmond used extensions when every holder of the standard role should get the new access, as with inquiry access for the customer service role, and new roles when the job was new to Cobalt Ridge, as with CR Quality engineer from the inspection certificate work. He avoided duplicating standard roles in code, because a copy does not receive the changes Microsoft makes to the original in later service updates.

Security in code and security as configuration

Administrators can also create and change roles, duties and privileges in the client, on the Security configuration page. Those changes are stored as data in the environment, not as metadata in a model. They can be exported and imported between environments, and the page lets administrators publish changes in a controlled way. Desmond drew a firm line: security that ships with a feature belongs in code, in the model, under source control, reviewed in a pull request and deployed in the package. Security that reflects how Cobalt Ridge assigns work, such as a role combining duties for a small team in CRMX, can be built as configuration by the security administrator. Both are valid; mixing them for the same object is how environments drift apart.

Segregation of duties

Segregation of duties is the control that stops one person from completing a risky process alone. Finance and operations apps support it with segregation of duties rules, which an administrator sets up by naming two duties that conflict. When a user would be assigned roles that together contain both duties, the system records a conflict. Depending on how the assignment is made, the conflicting assignment is either blocked or logged for review, and an administrator can approve an exception with a reason. The rules are data that an administrator maintains in the client, but they only work if developers design duties at the right grain.

In the inspection certificate work, Thandeka had required that the person who requests a waiver of a missing certificate is never the person who approves it. That rule could be written only because Desmond had built two duties, CR Request inspection waivers and CR Approve inspection waivers, instead of one broad duty for the whole waiver process. For the warranty module, Thandeka added a second rule: the duty to maintain warranties conflicts with the duty to void them. Prudence had to move the void privilege out of the maintain duty and into its own duty before the rule could be configured.

Two duties, CR Maintain pump warranties and CR Void pump warranties, connected by a red line labeled conflict rule. A user assignment that would give both duties is shown stopping at a review step where an administrator approves an exception with a reason or removes one role.
A segregation of duties rule names two conflicting duties; assignments that would combine them are blocked or logged for review.

CRMX made the point sharper. The Mexican company would start trading in January 2027 with eight people, and its single accounts clerk would hold duties that Thandeka's rules normally kept apart. Rather than weakening the rules, the design accepted the conflict for that one user with a recorded reason and a compensating control: the controller's approval of payment journals. Desmond's lesson for Prudence was that developers make such decisions possible by keeping duties small and named after what they let someone do.

Licenses and entry points

Security design also affects licensing. Each menu item carries properties that say which license a user needs when they have view or maintain access to it, and Microsoft's license reports in the client calculate a user's required license from the entry points their roles reach. A custom menu item that is set to require a higher license than the work justifies can raise the license requirement for everyone who receives it. Desmond asked Prudence to set the license properties on the warranty menu items deliberately, to match the standard customer service forms they sat beside, and to note her reasoning in the pull request so that Kiri could check it against the license plan.

Microsoft has changed how it enforces license requirements over the years, and the current rules are set out in the Dynamics 365 licensing guide and the user license reports. The developer's part does not change: choose license properties consciously, and avoid putting a lightweight task behind a menu item that drags in heavier license requirements.

Checking what a user can do

Before handing the design to Thandeka, Prudence tested it with real test users rather than with her own administrator account, which bypasses most checks and therefore proves nothing. She created three users in CONFIG: one with the customer service role, one with the warranty administrator role and one with the new CR Warranty void role. For each she ran the same short script: open the warranty list, open a warranty, try to edit the term, try to void it, print a certificate. She recorded what each user could and could not do in a table that went into the sign-off pack.

The client helps with this. On many forms, the Options menu offers security diagnostics that list which roles, duties and privileges grant access to the form and its controls. Administrators can also view the effective permissions of a role and the users assigned to it. Desmond showed Prudence how to read the diagnostics for the warranty form, which confirmed that only the maintain privilege gave Delete access and that the void button was controlled by the separate action menu item.

Prudence's test matrix for the warranty privileges, attached to the security sign-off.
Test user roleOpen listEdit termVoidPrint certificate
Service desk agent (extended)YesNoNoYes
CR Warranty administratorYesYesNoYes
CR Warranty voidYesNoYesYes

A checklist for every feature

Desmond ended the session by turning the conversation into a checklist that went into the CobaltRidgeCustom wiki. For every new feature: list every entry point; create view and maintain privileges, plus one for each sensitive action; group them into duties named in business language; add duties to roles through extensions or new roles, never through copies of standard roles; set license properties deliberately; tell the security administrator which duties should conflict; and test with users who hold only the intended roles. Thandeka read the checklist and asked for one more line: every change to an existing privilege must be listed in the release notes, because a change to what a privilege grants changes what every holder of that role can do.

Worked problem

Securing the warranty void action

Thandeka wants voiding a warranty limited to two named people, reviewed quarterly, and never held by someone who can also change warranty terms. How should Prudence design the security objects?

Show solution
  1. Keep the void logic behind its own action menu item, CRPumpWarrantyVoid, so it can be secured separately from the form.
  2. Create the privilege CRPumpWarrantyVoid with Invoke access on that menu item and nothing else.
  3. Create the duty CR Void pump warranties containing only that privilege, and remove the privilege from the maintain duty.
  4. Create a small role, CR Warranty void, holding the void and inquiry duties, so the two named people can be assigned it.
  5. Ask the security administrator to add a segregation of duties rule between CR Maintain pump warranties and CR Void pump warranties.
  6. Test with three users holding only the inquiry, maintain and void roles, and attach the results to the sign-off.

Answer: A dedicated action menu item, privilege, duty and role make the void permission visible, assignable to exactly two people and testable, and the narrow duties let Thandeka write the conflict rule she asked for.

Common mistakes

  • MistakeTesting security with an administrator account.

    InsteadTest with users who hold only the roles being designed.

  • MistakePutting a sensitive action inside the same privilege as ordinary maintenance.

    InsteadGive sensitive actions their own action menu item, privilege and duty.

  • MistakeCopying a standard role into the model to change it.

    InsteadExtend the standard role, or create a new role for a new job.

  • MistakeBuilding feature security on the Security configuration page in each environment.

    InsteadShip feature security in the model; keep configuration for company-specific arrangements.

Summary and key terms

  • Entry points such as menu items, service operations and data entities are unreachable until a privilege grants them.
  • Permissions carry access levels; privileges group permissions, duties group privileges, and roles group duties.
  • Feature security belongs in the model under source control; company-specific roles can be administered as configuration.
  • Segregation of duties rules name conflicting duties, so duties must be designed at the grain the rules need.
  • License properties on menu items affect the license that users need, and security must be tested with non-administrator users.
Entry point
An object through which a user or system reaches functionality, such as a menu item, service operation or data entity.
Privilege
A set of permissions on entry points that grants the access needed for one task.
Duty
A group of privileges that represents a business responsibility.
Role extension
An addition to a standard role made from another model without changing the role itself.
Segregation of duties rule
A rule naming two duties that should not be held by the same user.

Practice problems

Work each problem on paper first, then reveal the answer to check.

  1. Which access level does an action menu item use?

    Show answer

    Invoke.

  2. Where is a role limited to one legal entity?

    Show answer

    When the role is assigned to a user, by choosing specific organizations.

  3. Why did the void privilege have to leave the maintain duty?

    Show answer

    A segregation of duties rule compares duties, so the conflicting access had to be in a separate duty.

Lesson quiz · 5 questions

Score 60% or more to complete this lesson.

Take the quiz