AUA Framework Training — Episode 17

WebAuthorize & User Access Control

Mastering Authentication, Role-Based Authorization Attributes, and Security Infrastructure in AUA

Watch Video on YouTube

Enterprise Authentication & Authorization

Authentication and access control are critical pillars of secure software engineering. The AUA framework provides a robust user management module that empowers webmasters to define roles, assign granular permissions, and restrict resource access down to the individual controller action level with minimal performance overhead.

Using WebApiAuthorize Attribute

To enforce access control via WebApiAuthorize, each control or action must be registered in EUserAccess, and corresponding records (Name, Access Number, Description, and URL) must be seeded in the database UserAccess table.

Code Usage Example
[WebAuthorize(EUserAccess.AppUser)]
public IActionResult GetUserProfile()
{
    // Action limited to users with AppUser access (ID = 1)
}

Multi-Access Support: The attribute accepts multiple access levels; if a user satisfies at least one of the specified accesses, they are granted permission. Page titles are also automatically loaded based on the description configured in the User Access table.

Built-in Authorization Models in AUA

1. WebApiAuthorize

Specifies precise role/action-based access levels for controllers and actions.

2. AllowLoggedInAuthorization

Restricts resource access strictly to authenticated (logged-in) users.

3. OnlyLocalActionAuthorize

Restricts actions and controllers to local calls originating directly on the server.

4. AllowAnonymousAuthorize

Provides public, unrestricted access to the designated action or controller.

5. IpWebApiAuthorize

Restricts resource access dynamically based on predefined IP address ranges.

6. OnlyHasAccessTokenAuthorization

Requires the caller to present a valid operational access token.

1. Authorization Attribute & EUserAccess Enum

AppUserController.cs

Secure your Web API endpoints using the built-in [WebAuthorize] attribute mapped to the EUserAccess enum.

// 1. Enum Definition for Granular Access Levels
public enum EUserAccess : int
{
    [Description("User Management Access")]
    AppUser = 1,

    [Description("Role Management Access")]
    Role = 2
}

// 2. Controller Action Authorization Usage
[WebAuthorize(EUserAccess.AppUser)]
[HttpGet]
public async Task<ResultModel<AppUserDto>> GetByIdAsync(long id)
{
    var result = await _appUserService.GetByIdAsync(id);
    return Success(result);
}
“
”
"If you think good architecture is expensive, try bad architecture."
AUA Framework Philosophy

Official Channels & Community

Connect with the AUA Framework ecosystem.

Episode 17 Completed Access Levels