Skip to main content

Role-based Access Control (RBAC) & Permission Management

  • 2 minutes to read

Task-based Scenarios - Authentication

This example is based on the basic Authentication scenario and shows how to use our free .NET App Security & Web API Service to authorize CRUD and custom operations in your .NET MAUI application. To do this, we use role-based access control (RBAC) permissions linked to different user roles.

View Example: Role-Based Data Access

Related Controls: DXButton, TextEdit, PasswordEdit

Related APIs: FREE .NET App Security & Web API Service, PasswordEdit.StartIcon, TextEdit.StartIcon

Available users:

Username Password Role Permissions
Alex “123” Admin Create, Read, Update, Delete
Anthony “123” Admin Create, Read, Update, Delete
Dennis “123” Admin Create, Read, Update, Delete
Viewer Empty Viewer Read

Prerequisites

SQL Server, if you run this solution on Windows.

Anatomy

The solution contains the following projects:

Web API Service

We ran XAF’s Solution Wizard to generate a Web API Service that manages users. You can use this service to check whether a user exists in the database and their permissions.

Read Tutorial: Create a Standalone Web API Application

Watch Video: A 1-Click Solution for CRUD Web API with Role-based Access Control via EF Core & ASP.NET

The service contains the following endpoints:

Authenticate - accepts a username and a password as parameters. If a user’s password matches its hashed entry in the database, the Web API Service sends an authorization token to the client. The .NET MAUI Application can use it to call protected endpoints (request data).

Delete blog post - deletes a blog post if the user has the Admin role.

.NET MAUI Application
Implements the client app’s logic and UI (Login and Welcome pages). Uses the HttpClient class to communicate with the Web API Service.

The following diagram illustrates the scenario’s architecture:

Task-based Scenarios - Role-Based Diagram

Implementation Details

Refer to the following GitHub example for implementation details:

View Example: Role-Based Data Access

Previous Step

Form-Based Authentication (Login/Password) with the DevExpress Web API Service

See Also

The following example uses our free Web API Service to implement auto-generated OData endpoints/custom endpoints, authentication, and access permissions: How to Create a Web API Service Backend for a .NET MAUI Application

The example also downloads files and integrate DevExpress Reports with our Web API Service.