SC‑300 Study Portal Path 4

Unit 7: Create app roles

App roles are a core authorization feature in Microsoft Entra ID and should be deliberately configured during app registration. An app role is a custom authorization claim that can be assigned to users, groups, or applications. When a user or application authenticates, Microsoft Entra ID includes the assigned app roles in the issued token. Your application then uses this role information to make authorization decisions at runtime.

Unlike authentication, which answers who the user is, app roles focus on what the user is allowed to do inside the application. This separation is important for building secure and maintainable applications.

Why App Roles Exist

App roles provide a built-in, identity-native way to implement role-based access control (RBAC) directly in your application. Instead of relying on external group lookups or hard-coded logic, roles are issued as part of the authentication token and can be trusted by the application.

This design allows authorization decisions to be consistent, auditable, and centrally managed through Microsoft Entra ID.

Key Benefits of App Roles

App roles provide several advantages over traditional group-based authorization.

Alternative to group claims. App roles reduce or eliminate the need to rely on Microsoft Entra group claims, which helps avoid group overage issues and does not require Microsoft Entra ID P1 licensing.

Fine-grained authorization. App roles enable precise control over what users can do inside the application, such as read-only access versus administrative access.

Simplified application code. Your application can check for a specific role value instead of mapping group IDs or maintaining complex lookup logic.

To use app roles effectively, you must define them in the app registration and explicitly allow Users/Groups as member types when creating the role.

Defining App Roles

App roles are defined in the app registration. When creating a role, you specify:

A display name that is shown to administrators.

A value that appears in the token.

A description that explains the role’s purpose.

The allowed member types, such as Users/Groups or Applications.

Whether the role is enabled.

Selecting Users/Groups allows administrators to assign the role to users and security groups through the Enterprise applications blade.

How App Roles Appear in Tokens

After app roles are defined, IT administrators assign users or groups to those roles. When a user signs in, Microsoft Entra ID includes a roles claim in the token.

ID tokens include roles for applications.

Access tokens include roles for APIs.

Example token excerpt

"roles": [

"Approver",

"Reviewer"

]

Your application should use this roles claim to enforce authorization logic. For example, a user with the Approver role might be allowed to approve requests, while a user with the Reviewer role can only view data.

Best Practices for App Roles

Careful role design is critical for security and usability.

Always define a baseline user role. When app roles allow users and groups, you should always define a default or baseline role, such as User or Reader, that has no elevated privileges. When assignment is required, only users assigned to the app (directly or through a group) can access it.

Avoid auto-assigning elevated roles. If your app defines only an elevated role such as Admin, all assigned users would receive that role automatically. This violates the principle of least privilege and is a common design mistake.

Use explicit role assignment. When assigning a user or group to an application, an app role must be selected as part of the assignment. This ensures that authorization intent is explicit and auditable.

Use clear and descriptive role names. Role names such as Admin, Editor, and Viewer clearly communicate intent and reduce confusion compared to group IDs or opaque identifiers.

Advantages of Using App Roles Instead of Groups

App roles offer multiple advantages beyond avoiding group overage claims.

Simplified authorization logic. Your application can directly check for a role value instead of iterating through group claims and mapping group IDs to permissions.

Improved security clarity. Role names convey meaning, making it easier to review access and detect misconfigurations.

Better portability. App roles can be recreated consistently across development, test, and production environments without relying on tenant-specific group IDs.

For SC-300, it is important to understand that app roles are an application-level authorization mechanism, not a replacement for directory roles, and they are evaluated entirely by the application consuming the token.