aspnetcore-authorization

Configure policy-based and scope-based authorization in ASP.NET Core applications.

10|2|Updated Mar 16, 2026
One-click install
npx skills add https://github.com/DuendeSoftware/duende-skills --skill aspnetcore-authorization
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: aspnetcore-authorization
Source: https://github.com/DuendeSoftware/duende-skills/tree/main/skills/aspnetcore-authorization
Command: npx skills add https://github.com/DuendeSoftware/duende-skills --skill aspnetcore-authorization

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

ASP.NET Core applications often require complex authorization logic spanning policies, scopes, resources, and minimal APIs. This Skill provides proven patterns to implement robust access control.

Core Features & Use Cases

  • Policy-based authorization with customizable requirements and handlers.
  • Scope-based and claims-based checks for APIs using OAuth/OIDC.
  • Resource-based authorization with IAuthorizationService for per-resource decisions.
  • Minimal API and group-level patterns with safe defaults.
  • Guidance on avoiding hard-coded roles and ensuring authentication/authorization separation.

Quick Start

Configure policy-based and scope-based authorization in ASP.NET Core applications to protect endpoints.

Frequently Asked Questions about aspnetcore-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 minimal APIs?

Policy-based authorization in ASP.NET Core minimal APIs is implemented by defining customizable requirements and handlers, then applying safe defaults at the endpoint or group level to protect routes without relying on hard-coded roles.

What's the best way to handle resource-based authorization with IAuthorizationService?

Resource-based authorization uses IAuthorizationService to evaluate per-resource access decisions, passing both the user and the specific resource to custom handlers to enforce precise access control rather than broad role checks.

How do I configure scope-based and claims-based checks for APIs using IdentityServer?

Scope-based and claims-based checks for APIs using IdentityServer are configured during startup by defining OAuth/OIDC policies that validate scopes and claims, enforcing separation between authentication and authorization.

Can I use custom authorization handlers with ASP.NET Core Razor Pages and controllers?

Custom authorization handlers are fully supported across ASP.NET Core Razor Pages and controllers, allowing you to register policy definitions and apply them via attributes or explicit checks to secure endpoints consistently.

Why should I avoid hard-coded roles in ASP.NET Core authorization?

Avoiding hard-coded roles in ASP.NET Core authorization ensures flexible, maintainable access control by shifting to policy-based and claims-based logic that adapts to changing requirements without modifying application code.

Does ASP.NET Core authorization support OpenID Connect for endpoint protection?

ASP.NET Core authorization supports OpenID Connect for endpoint protection by integrating OIDC authentication with policy and scope-based authorization to establish secure defaults across APIs and web apps.