liveBook · Manning

Permission

As explained in Building Web APIs with ASP.NET Core

A permission is an authorization grant allowing a user or role to perform a specified operation on a resource.

A permission is an access privilege: it allows or denies a particular action on a resource. A web API might permit a user to read an endpoint but not update or delete data. Authorization checks those privileges; authentication establishes who the user is so the system can make that check. section 9.1.2

An access control list (ACL) describes which users or groups may perform actions such as reading, writing, or deleting a resource. Anonymous users usually receive only the lowest level of access, such as public content. After login, the system can check the authenticated user’s privileges and decide whether to allow access to restricted resources. section 9.1.2

Permissions for a board-game API

Suppose the API needs three levels of access. Ordinary users have the same permissions as anonymous users. Moderators can use read-only and update endpoints, but cannot delete data or seed the database. Administrators can read, update, delete, and seed. A parameterless [Authorize] attribute checks whether a user is authenticated; by itself, it does not distinguish moderators from administrators. section 9.4

In ASP.NET Core, role-based access control puts those distinctions into practice:

  • Create Moderator and Administrator roles, then assign the relevant users to them. Each role acts as a group whose authorization rules apply to its members. section 9.4
  • Include each user’s roles as claims in their JWT so the authorization middleware can recognize them. section 9.4
  • Set role requirements on the action methods that need moderator or administrator access, rather than relying only on a parameterless [Authorize] attribute. section 9.4

Check the result with users in each role: an authenticated user should not gain administrator access merely by logging in, a moderator should be blocked from deletion and seeding, and an administrator should be allowed to perform both. section 9.4

How Building Web APIs with ASP.NET Core covers it

How deep it goes
Defines permissions through ACLs and outlines steps for assigning role-based rules; stops short of showing complete code in the supplied evidence.
Examples
Uses read, update, delete, and database-seeding endpoints to distinguish ordinary users, moderators, and administrators.
What it assumes
Introduces permissions and ACLs in plain terms, then assumes familiarity with API action methods when outlining ASP.NET Core configuration.
What you can do after
Apply it via ASP.NET Core roles, JWT role claims, and [Authorize] requirements to restrict API actions.
How it connects
Links permissions to authentication, authorization, access control lists, role-based access control, JWT claims, and authorization middleware.

Also explained in

Compare how 4 books explain permission →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Building Web APIs with ASP.NET Core. The section links point to the parts of the book it draws on.