Agent skill
orchardcore-security
Skill for configuring security and authorization in Orchard Core. Covers permission definitions, authorization services, CORS, security headers, content security policies, and OpenID Connect.
Install this agent skill to your Project
npx add-skill https://github.com/majiayu000/claude-skill-registry/tree/main/skills/other/other/orchardcore-security
Metadata
Additional technical details for this skill
- author
- CrestApps Team
- version
- 1.0
SKILL.md
Orchard Core Security - Prompt Templates
Configure Security and Authorization
You are an Orchard Core expert. Generate security and authorization configurations for Orchard Core.
Guidelines
- Orchard Core provides a granular permission system for access control.
- Use
IAuthorizationServicefor permission checks in code. - Content-level permissions can restrict access per content type.
- Enable HTTPS redirection and security headers in production.
- OpenID Connect support is built-in for OAuth/OIDC authentication.
- CORS policies can be configured for API access.
- Rate limiting and anti-forgery protection are available.
Enabling Security Features
{
"steps": [
{
"name": "Feature",
"enable": [
"OrchardCore.Security",
"OrchardCore.Cors",
"OrchardCore.ReverseProxy"
],
"disable": []
}
]
}
Security Headers Configuration
Configure security headers through settings:
{
"steps": [
{
"name": "Settings",
"SecurityHeadersSettings": {
"ContentSecurityPolicy": "default-src 'self'; script-src 'self' 'unsafe-inline'; style-src 'self' 'unsafe-inline'",
"PermissionsPolicy": "camera=(), microphone=(), geolocation=()",
"ReferrerPolicy": "strict-origin-when-cross-origin",
"ContentTypeOptions": "nosniff",
"XFrameOptions": "SAMEORIGIN"
}
}
]
}
CORS Configuration via Recipe
{
"steps": [
{
"name": "CorsSettings",
"Policies": [
{
"Name": "Default",
"AllowedOrigins": ["https://example.com"],
"AllowedMethods": ["GET", "POST"],
"AllowedHeaders": ["Content-Type", "Authorization"],
"AllowCredentials": true
}
],
"DefaultPolicyName": "Default"
}
]
}
OpenID Connect Server Setup
Enable Orchard Core as an OAuth/OIDC provider:
{
"steps": [
{
"name": "Feature",
"enable": [
"OrchardCore.OpenId",
"OrchardCore.OpenId.Server",
"OrchardCore.OpenId.Validation"
],
"disable": []
}
]
}
OpenID Server Settings
{
"steps": [
{
"name": "Settings",
"OpenIdServerSettings": {
"Authority": "https://{{YourDomain}}",
"TokenEndpointPath": "/connect/token",
"AuthorizationEndpointPath": "/connect/authorize",
"LogoutEndpointPath": "/connect/logout",
"UserinfoEndpointPath": "/connect/userinfo",
"AllowAuthorizationCodeFlow": true,
"AllowClientCredentialsFlow": true,
"AllowRefreshTokenFlow": true
}
}
]
}
OpenID Application Registration
{
"steps": [
{
"name": "OpenIdApplication",
"OpenIdApplications": [
{
"ClientId": "{{ClientId}}",
"DisplayName": "{{ApplicationName}}",
"Type": "confidential",
"AllowAuthorizationCodeFlow": true,
"AllowRefreshTokenFlow": true,
"RedirectUris": "https://{{ClientDomain}}/callback",
"PostLogoutRedirectUris": "https://{{ClientDomain}}/signout-callback"
}
]
}
]
}
Content-Level Permissions
using OrchardCore.Security.Permissions;
public sealed class ContentPermissions : IPermissionProvider
{
public static readonly Permission ViewOwnContent =
new("ViewOwnContent", "View own content items", new[] { CommonPermissions.ViewContent });
public static readonly Permission EditOwnContent =
new("EditOwnContent", "Edit own content items", new[] { CommonPermissions.EditContent });
public Task<IEnumerable<Permission>> GetPermissionsAsync()
{
return Task.FromResult<IEnumerable<Permission>>(new[]
{
ViewOwnContent,
EditOwnContent
});
}
public IEnumerable<PermissionStereotype> GetDefaultStereotypes()
{
return new[]
{
new PermissionStereotype
{
Name = "Authenticated",
Permissions = new[] { ViewOwnContent, EditOwnContent }
}
};
}
}
Content Authorization Handler
using OrchardCore.ContentManagement;
using OrchardCore.Contents.Security;
public sealed class MyContentAuthorizationHandler : AuthorizationHandler<PermissionRequirement>
{
protected override Task HandleRequirementAsync(
AuthorizationHandlerContext context,
PermissionRequirement requirement)
{
if (context.Resource is ContentItem contentItem)
{
// Custom authorization logic
if (contentItem.Owner == context.User.Identity.Name)
{
context.Succeed(requirement);
}
}
return Task.CompletedTask;
}
}
Reverse Proxy Configuration
When behind a reverse proxy (nginx, Azure, etc.):
{
"OrchardCore": {
"OrchardCore_ReverseProxy": {
"ForwardedHeaders": "XForwardedFor,XForwardedHost,XForwardedProto"
}
}
}
Anti-Forgery Configuration
Anti-forgery tokens are automatically included in Orchard Core forms. For API endpoints:
[HttpPost]
[IgnoreAntiforgeryToken] // Only for API endpoints with token auth
public async Task<IActionResult> ApiEndpoint()
{
// API logic
}
Recommended Agent Skills
Expand your agent's capabilities with these related and highly-rated skills.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
agent-ops-spec
Manage specification documents in .agent/specs/. Use when user provides requirements, acceptance criteria, or feature descriptions that need to be tracked and validated against implementation.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-testing
Test strategy, execution, and coverage analysis. Use when designing tests, running test suites, or analyzing test results beyond baseline checks.
agent-ops-state
Maintain .agent state files. Use at session start, after meaningful steps, and before concluding: read/update constitution/memory/focus/issues/baseline consistently.
Didn't find tool you were looking for?