Configures security and authorization in Orchard Core: permissions, authorization checks, security headers, API authentication, and Problem Details error responses.
Ships in orchardcore. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
You are an Orchard Core expert. Generate security and authorization configurations for Orchard Core.
IAuthorizationService.AuthorizeAsync(User, permission[, resource]).*Permissions class (usually in an Abstractions or Core project, so other modules can reference them without depending on your module) and return them from an IPermissionProvider.Permission.Description is a LocalizationSource in 4.0. Create it with LocalizationSource.Create("text", typeof(DeclaringType)) or LocalizationSource.Create<DeclaringType>("text") so the PO-file context is preserved. The constructors taking a string description are [Obsolete] and create context-free descriptions. A source is never serialized, so Description is not part of the JSON of a Permission or a PermissionTemplate.PermissionTemplate and its CreateDynamicPermission(...), not with a Permission holding {0} placeholders (see orchardcore-permission-providers).isSecurityCritical: true.ViewContent, EditContent, PublishContent, DeleteContent, and their Own variants) live in OrchardCore.Contents.CommonPermissions; pass the content item as the resource so dynamic per-type permissions apply.OrchardCore.Security adds security headers configured from Settings → Security → Security Headers (permission ManageSecurityHeadersSettings).Api scheme (OrchardCoreConstants.AuthenticationSchemes.Api), which accepts bearer tokens (for example from OrchardCore.OpenId.Validation) and never cookies.orchardcore-cors, orchardcore-https, orchardcore-reverse-proxy, orchardcore-openid, orchardcore-openapi, orchardcore-rate-limits, orchardcore-antivirus, orchardcore-file-upload-security, orchardcore-localization-source, orchardcore-users-roles.{ "steps": [...] } format.sealed modifier, except View Models.{
"steps": [
{
"name": "feature",
"enable": [
"OrchardCore.Security",
"OrchardCore.Https",
"OrchardCore.Cors",
"OrchardCore.ReverseProxy",
"OrchardCore.RateLimits"
]
}
]
}
{
"steps": [
{
"name": "settings",
"SecuritySettings": {
"ContentTypeOptions": "nosniff",
"ReferrerPolicy": "strict-origin-when-cross-origin",
"ContentSecurityPolicy": {
"default-src": "'self'",
"script-src": "'self'",
"style-src": "'self' 'unsafe-inline'",
"frame-ancestors": "'self'"
},
"PermissionsPolicy": {
"camera": "()",
"microphone": "()",
"geolocation": "()"
}
}
}
]
}
frame-ancestors replaces the obsolete X-Frame-Options header. Admin scripts in 4.0 load as ES modules without jQuery; test a strict script-src against the admin before removing 'unsafe-inline' for the whole site.
Call ConfigureSecuritySettings() to let configuration override the admin values. The settings page then shows that values come from configuration.
builder.Services
.AddOrchardCms()
.ConfigureSecuritySettings();
{
"OrchardCore": {
"Security": {
"ContentSecurityPolicy": {
"default-src": "'self'"
},
"PermissionsPolicy": {
"fullscreen": "self"
},
"ReferrerPolicy": "no-referrer"
}
}
}
using OrchardCore;
using OrchardCore.Localization;
using OrchardCore.Security.Permissions;
namespace MyModule;
public static class InvoicePermissions
{
public static readonly Permission ManageInvoices = new(
"ManageInvoices",
LocalizationSource.Create("Manage invoices", typeof(InvoicePermissions)),
isSecurityCritical: true);
public static readonly Permission ViewInvoices = new(
"ViewInvoices",
LocalizationSource.Create("View invoices", typeof(InvoicePermissions)),
[ManageInvoices]);
}
public sealed class Permissions : IPermissionProvider
{
private readonly IEnumerable<Permission> _allPermissions =
[
InvoicePermissions.ManageInvoices,
InvoicePermissions.ViewInvoices,
];
public Task<IEnumerable<Permission>> GetPermissionsAsync()
=> Task.FromResult(_allPermissions);
public IEnumerable<PermissionStereotype> GetDefaultStereotypes() =>
[
new PermissionStereotype
{
Name = OrchardCoreConstants.Roles.Administrator,
Permissions = _allPermissions,
},
];
}
Register it with services.AddPermissionProvider<Permissions>(); (an internal sealed provider works too). The third constructor argument lists permissions that imply this one. Stereotypes are granted when the feature is installed and when a matching role is created; a role created while an installed feature is disabled gets them when the feature is enabled again, including for internal providers since 4.0 (see orchardcore-permission-providers). Display a description with IStringLocalizerFactory.Localize(permission.Description); read the raw text with permission.Description.Value.
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using OrchardCore.ContentManagement;
using OrchardCore.Contents;
namespace MyModule.Controllers;
public sealed class InvoiceController : Controller
{
private readonly IAuthorizationService _authorizationService;
private readonly IContentManager _contentManager;
public InvoiceController(
IAuthorizationService authorizationService,
IContentManager contentManager)
{
_authorizationService = authorizationService;
_contentManager = contentManager;
}
public async Task<IActionResult> Display(string contentItemId)
{
var contentItem = await _contentManager.GetAsync(contentItemId);
if (contentItem == null)
{
return NotFound();
}
if (!await _authorizationService.AuthorizeAsync(User, CommonPermissions.ViewContent, contentItem))
{
return Forbid();
}
return View(contentItem);
}
}
using Microsoft.AspNetCore.Authorization;
using OrchardCore.ContentManagement;
using OrchardCore.Security;
namespace MyModule.Security;
public sealed class InvoiceOwnerAuthorizationHandler : AuthorizationHandler<PermissionRequirement>
{
protected override Task HandleRequirementAsync(
AuthorizationHandlerContext context,
PermissionRequirement requirement)
{
if (requirement.Permission.Name == InvoicePermissions.ViewInvoices.Name &&
context.Resource is ContentItem contentItem &&
contentItem.Owner == context.User.FindFirst(System.Security.Claims.ClaimTypes.NameIdentifier)?.Value)
{
context.Succeed(requirement);
}
return Task.CompletedTask;
}
}
Register with services.AddScoped<IAuthorizationHandler, InvoiceOwnerAuthorizationHandler>();. ContentItem.Owner stores the user ID.
Secure API endpoints with the Api scheme and return Problem Details:
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using OrchardCore;
namespace MyModule.Controllers;
[ApiController]
[Route("api/invoices")]
[Authorize(AuthenticationSchemes = OrchardCoreConstants.AuthenticationSchemes.Api)]
public sealed class InvoiceApiController : ControllerBase
{
private readonly IAuthorizationService _authorizationService;
public InvoiceApiController(IAuthorizationService authorizationService)
{
_authorizationService = authorizationService;
}
[HttpGet("{id}")]
public async Task<IActionResult> Get(string id)
{
if (!await _authorizationService.AuthorizeAsync(User, InvoicePermissions.ViewInvoices))
{
return this.ApiForbidProblem();
}
return this.ApiNotFoundProblem();
}
}
401 and 403 responses produced by the Api scheme, and error responses of endpoints marked [SkipStatusCodePages], carry an RFC 9457 application/problem+json body. Other error responses still go to the OrchardCore.Diagnostics error pages.WWW-Authenticate (RFC 6750 error details) still comes from the authentication handler. The body is written through IProblemDetailsService, so services.AddProblemDetails(options => ...) customizations apply. AddOrchardCms() enables it; hosts built with AddOrchardCore() call .AddApiProblemDetails().ControllerBase and HttpContext: ApiForbidProblem(), ApiBadRequestProblem(), ApiNotFoundProblem(), ApiValidationProblem(). In minimal APIs, httpContext.ChallengeOrForbid(OrchardCoreConstants.AuthenticationSchemes.Api) returns the right challenge.[SkipStatusCodePages] (or .WithMetadata(new SkipStatusCodePagesAttribute())) to JSON endpoints that use cookie authentication so their errors are not replaced by HTML pages.Orchard Core forms include anti-forgery tokens automatically. Only bypass validation for endpoints that authenticate with bearer tokens:
[HttpPost]
[IgnoreAntiforgeryToken]
[Authorize(AuthenticationSchemes = OrchardCoreConstants.AuthenticationSchemes.Api)]
public IActionResult Import()
{
return Ok();
}
Minimal APIs use .DisableAntiforgery() together with the Api scheme.
OrchardCore.Users.CommonPermissions.* → OrchardCore.Users.UsersPermissions.*OrchardCore.Deployment.CommonPermissions.* → OrchardCore.Deployment.DeploymentPermissions.*OrchardCore.Apis.GraphQL.CommonPermissions.* → OrchardCore.Apis.GraphQL.GraphQLPermissions.*OrchardCore.Media.Permissions.* → OrchardCore.Media.MediaPermissions.*OrchardCore.OpenId.Permissions.* → OrchardCore.OpenId.OpenIdPermissions.*OrchardCore.Settings.Permissions.ManageSettings → OrchardCore.Settings.SettingsPermissions.ManageSettingsOrchardCore.Security.StandardPermissions.SiteOwner → removed; assign users to the Administrator role.CS0618 warning. Use the member with the same name, not the one named in the old obsolete message (AdminMenu ManageAdminMenu/ViewAdminMenuAll and CommonPermissions.CreateAssignRoleToUsersPermission returned the wrong permission in 3.x).Permission.Description changed from string to LocalizationSource; recompile modules. Translations of built-in descriptions now come from PO files, not Data Localization.new Permission(name, "string description", ...) is [Obsolete]; pass a LocalizationSource. Dynamic permission templates are PermissionTemplate instances (for example ContentTypePermissionsHelper.PermissionTemplates values), and ContentTypePermissionsHelper.CreateDynamicPermission(...)/ConvertToDynamicPermission(...) are [Obsolete] in favor of CreateDynamicPermissionOf(...)/GetPermissionTemplate(...).OrchardCore_Security and OrchardCore_ReverseProxy configuration sections are now OrchardCore:Security and OrchardCore:ReverseProxy (old names still work but are deprecated).401/403 responses now have a Problem Details body instead of an empty one.Official Orchard Core videos shown on the documentation page:
What SKILL.md sets; muted values are Claude Code's defaults
/orchardcore:orchardcore-securityfrom orchardcore
npx claudepluginhub crestapps/crestapps.agentskills --plugin orchardcore140 skills in this plugin
/orchardcore-adminGuidance for the Orchard Core admin panel, including admin controllers and routes, admin menu registration with AdminNavigationProvider, ocat editor forms grouped in cards, admin pages rendering Model.Editor, the UI text casing standard, TheAdmin layout and menu colors, admin branding, the Navbar shape, the Ctrl+K quick navigation palette and QuickNavigationSource, AdminSettings such as MenuBehavior, ShowBreadcrumb, DisplayQuickNavigation, DisplayTitlesInTopbar and ActionsLayout, the AdminDashboard shape, settings pages, and admin filters and zones. Use this skill when requests mention the Orchard Core admin panel, TheAdmin, admin controllers, admin menu registration, an icon on an admin menu item, the AdminSettings recipe step, quick navigation, navigation menu behavior, the admin URL prefix, UI text casing. Strong matches include OrchardCore.Admin, AdminSettings, AdminPermissions, AdminOptions, AdminAttribute, SiteDisplayDriver, IDisplayManager./orchardcore-admin-dashboardSkill for creating admin dashboard widgets in Orchard Core. Covers the DashboardWidget stereotype, DashboardPart position and sizing, the built-in HtmlDashboardWidget, ContentsMetadata and ContentsTags widget types, custom widget content types via recipe or migration, arranging widgets in Manage Dashboard mode, widget template customization, provisioning widgets with recipes, dashboard permissions, the DashboardBreadcrumbProvider Dashboard ancestor, and the AdminDashboardContent shape used when the feature is disabled. Use this skill when requests mention Orchard Core Admin Dashboard, Create and Configure Dashboard Widgets, Enabling Admin Dashboard, Widget Configuration Properties, dashboard widget recipes, Dashboard breadcrumb, or related implementation, setup, or troubleshooting work. Strong matches include OrchardCore.AdminDashboard, DashboardPart, DashboardBreadcrumbProvider, AccessAdminDashboard, ManageAdminDashboard.Other plugins' skills for the same job