Skip to content

Custom ASP.NET Core project demonstrating dynamic authorization policies for flexible and parameterized security.

License

Notifications You must be signed in to change notification settings

JohnSalazar/AspNetCoreIdentityAuthorizationCustom

Repository files navigation

AspNetCoreIdentityAuthorizationCustom

This project demonstrates how to implement custom authorization policies in ASP.NET Core using the IAuthorizationPolicyProvider.

The goal is to provide a solution for scenarios where policies cannot be registered statically or when policies based on dynamic parameters are required.

Key Features

  • Custom Policy Provider: Implements a custom IAuthorizationPolicyProvider that dynamically generates authorization policies based on specific requirements.

  • Custom Authorization Attribute: Defines an authorization attribute that accepts parameters, enabling the application of policies based on dynamic conditions directly on controllers or actions.

  • Custom Requirement Handlers: Includes handlers that evaluate the policy requirements at runtime, determining whether a user meets the defined criteria.

Project Structure

  • Controllers/: Contains MVC controllers that demonstrate the application of custom authorization policies.

  • Data/: Includes classes related to data access and Entity Framework Core configuration.

  • Identity/: Houses implementations related to identity and authorization, including the custom policy provider and requirement handlers.

  • Migrations/: Contains Entity Framework Core migrations to configure the database schema.

Prerequisites

  • ASP.NET Core 6.0 or later.
  • Entity Framework Core for data access.

How to Run the Project

  1. Clone the repository:

    git clone https://github.com/JohnSalazar/AspNetCoreIdentityAuthorizationCustom.git
  2. Navigate to the project directory:

    cd AspNetCoreIdentityAuthorizationCustom
  3. Restore dependencies:

    dotnet restore
  4. Update the database:

    dotnet ef database update
  5. Run the application:

    dotnet run

References


This project serves as a practical guide for developers looking to implement more flexible and dynamic authorization solutions in their ASP.NET Core applications.


This project was developed by JohnSalazar Brazil under the MIT license.

About

Custom ASP.NET Core project demonstrating dynamic authorization policies for flexible and parameterized security.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages