permission-authorization

Implement permission-based authorization in .NET apps with HasPermission attributes and dynamic policies.

69|13|Updated Jan 26, 2026
One-click install
npx skills add https://github.com/ronnythedev/dotnet-clean-architecture-skills --skill permission-authorization
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: permission-authorization
Source: https://github.com/ronnythedev/dotnet-clean-architecture-skills/tree/main/sample/POS/.claude/skills/13-permission-authorization
Command: npx skills add https://github.com/ronnythedev/dotnet-clean-architecture-skills --skill permission-authorization

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill provides a centralized, declarative approach to enforcing permissions in .NET applications, replacing scattered role checks with a consistent policy-based model.

Core Features & Use Cases

  • HasPermission attribute for endpoints
  • Dynamic policy provider that creates policies on the fly
  • Role-to-permission transformation via claims
  • Use case: restrict admin endpoints to specific permissions, map user roles to allowed actions

Quick Start

Configure services.AddPermissionAuthorization() and apply [HasPermission] attributes to protect endpoints. Ensure RoleToPermissionClaimsTransformation and the PermissionAuthorizationHandler are registered.

Frequently Asked Questions about permission-authorization

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement fine-grained permission-based authorization in .NET?

Fine-grained permission-based authorization in .NET is implemented by applying a declarative HasPermission attribute to endpoints and using a dynamic PolicyProvider to create policies on the fly. This replaces scattered role checks with a centralized policy model.

What is the best way to map user roles to permissions in ASP.NET Core?

The best way to map user roles to permissions in ASP.NET Core is using a RoleToPermissionClaimsTransformation. This mechanism converts role assignments into specific permission claims, which the PermissionAuthorizationHandler then evaluates against dynamic policies.

How do I dynamically generate authorization policies for API endpoints?

Dynamically generating authorization policies for API endpoints is handled by a dynamic PolicyProvider. It creates policies on the fly to satisfy HasPermission attributes, ensuring declarative access control is enforced without manually registering each policy.

Can I use declarative access control for services and UI layers in .NET?

Yes, declarative access control applies to API endpoints, services, and UI layers in .NET. You apply the HasPermission attribute across these layers to uniformly restrict actions based on dynamically generated policies and transformed claims.

How do I configure permission authorization in my .NET application?

Configuring permission authorization in a .NET application requires calling services.AddPermissionAuthorization(). You must also register the RoleToPermissionClaimsTransformation and the PermissionAuthorizationHandler to apply HasPermission attributes correctly.

Related Skills