This project contains a example of using the AuthPermissions.AspNetCore library in ASP.NET Core razor page web app with user data provided by the individual accounts approach. This is one of the simplest approaches using:
This article (!!! LINK !!!) details how this example was built, and how it works.
- Application: ASP.NET Core, Razor Pages
- AuthorizationProvider: ASP.NET Core's individual accounts
- CookieOrToken: Cookie
- MultiTenant: not used
- Databases: Two databases
- Individual accounts: InMemoryDatabase:
- AuthPermissions: In-memory database (uses SQLite in-memory).
- Focused on: The basics of the AuthPermissions authorization system.
The ASP.NET Core code comes comes from the ASP.NET Core documentation on building razor page web app individual accounts authorization, but the handling of the visibilty of the contact manager features are handled by the AuthPermissions.AspNetCore library.
The AuthPermissions.AspNetCore code/features used in this example
- Adding the AuthPermissions into your ASP.NET Core application.
- Bulk loading AuthPermissions Roles and Users.
- Mapping the user's Roles to Permissions.
- Authorization in razor pages via the
[HasPermission(<enum permission>)]
attribute on thePageModel
class. - Authorization in razor pages via the
User.HasPermission(<enum permission>)
method. - Add SuperUser on startup feature.
NOTE: This example does not include the admin pages for
NOTE: This article provides a good overview of the standard ASP.NET Core authorization approaches.