authorization

Implements RBAC authorization with permission policies, JWT claims, and React permission guards for ERP systems.

Updated Aug 18, 2026
One-click install
npx skills add https://github.com/Aurelian1974/ERPEnterprise --skill authorization-aurelian1974
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: authorization
Source: https://github.com/Aurelian1974/ERPEnterprise/tree/main/.github/skills/authorization
Command: npx skills add https://github.com/Aurelian1974/ERPEnterprise --skill authorization-aurelian1974

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Building consistent role-based access control across an ERP backend and frontend is error-prone: permissions get hardcoded as strings, policies drift from permission names, and UI buttons stay visible to unauthorized users. This Skill provides a complete, convention-driven RBAC implementation covering permission definition, policy registration, controller enforcement, handler-level checks, and frontend guards. ## Core Features & Use Cases - Permission Definition & Policy Registration: Define permissions as {module}.{entity}.{action} constants in static Domain classes and auto-register ASP.NET Core authorization policies from them, eliminating manual mapping. - Multi-Layer Enforcement: Apply [Authorize(Policy)] on every controller action, verify tenant ownership in MediatR handlers via ICurrentUser, and embed permissions as JWT claims with wildcard super-admin support. - Frontend Permission Guards: Use a usePermission React hook to conditionally render destructive or sensitive actions based on the user's permission set. - Use Case: When adding a new "approve invoice" endpoint to a finance module, generate the permission constant, register its policy, protect the controller action, verify tenant ownership in the handler, seed the permission in SQL Server, and hide the Approve button for unauthorized users. ## Quick Start Ask the AI to add authorization with a new permission for an endpoint, for example: add an approve permission for finance invoices and protect the endpoint, handler, and UI button.

Frequently Asked Questions about authorization

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

FAQPage Schema
How do I implement policy-based authorization in ASP.NET Core?▼

Define permissions as constants in a static class, then register one policy per permission in Program.cs using a custom IAuthorizationRequirement and AuthorizationHandler. Apply them with [Authorize(Policy = Permission.Constant)] on each controller action.

How to check user permissions in a React app?▼

Store the user's permissions in an auth store after login, then create a usePermission hook that checks whether the permission list contains the required permission or a wildcard. Use it to conditionally render sensitive buttons like approve or delete.

How do I add resource-level authorization in a MediatR handler?▼

Inject an ICurrentUser service into the handler and compare the entity's TenantId against the current user's tenant claim after loading it from the repository. Return a forbidden error result when they do not match, keeping HttpContext out of the handler.

Should permissions be stored in JWT claims or checked against the database?▼

This approach embeds permissions as individual claims in the JWT at token generation, so the authorization handler reads them without database calls. Permissions are also seeded per tenant in SQL Server for role assignment and management.

What naming convention should I use for RBAC permissions?▼

Use the format {module}.{entity}.{action}, such as finance.invoices.approve, with standard actions like view, create, update, delete, approve, export, and admin. A wildcard "*" grants all permissions for super admin users.