discourse-acl-authoring

Guides creation and review of ACL-backed permission features in Discourse core and plugins.

47.8k|9.0k|Updated Jan 12, 2013
One-click install
npx skills add https://github.com/discourse/discourse --skill discourse-acl-authoring
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: discourse-acl-authoring
Source: https://github.com/discourse/discourse/tree/main/.skills/discourse-acl-authoring
Command: npx skills add https://github.com/discourse/discourse --skill discourse-acl-authoring

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Building access-control-list features in Discourse involves many moving parts—models, Guardian helpers, the write manager, site metadata, and frontend components—and mistakes like bypassing AccessControlListManager or skipping mandatory ACL injection create security gaps. This Skill provides the authoritative workflow and non-negotiable rules for implementing ACL-backed permissions correctly.

Core Features & Use Cases

  • Backend ACL Modeling: Covers AccessControlList, AclTarget concern, Acl::Target/Acl::User lookup objects, Guardian helpers, mandatory/banned ACLs, and loss warning permissions.
  • Write Path & Plugin Integration: Enforces routing all writes through AccessControlListManager, registering plugin target classes with DiscoursePluginRegistry, and exposing metadata via Site#access_control.
  • Frontend Components: Documents DAccessControl and DAccessControlField usage, FormKit integration, permission option transforms, and loss-confirmation flows.
  • Use Case: When adding a permission system to a Discourse plugin (e.g., a kanban board with view/edit/manage grants), use this Skill to wire the model, service, serializer, and UI correctly with full test coverage.

Quick Start

Use the discourse-acl-authoring skill to add ACL-backed view and manage permissions to my plugin's Board model with a FormKit editor.

Frequently Asked Questions about discourse-acl-authoring

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

FAQPage Schema
How do I add ACL permissions to a Discourse plugin model?

Include the AclTarget concern in your model, register the class with DiscoursePluginRegistry.register_acl_target_class after initialization, and route all writes through AccessControlListManager. Define mandatory_acl or banned_acl class methods when certain grants must always exist or never be allowed.

How do I write ACL rows in Discourse?

Always call AccessControlListManager with the guardian, target, flattened ACL array, and owner string. Authorize the actor before calling it, since the manager destructively replaces ACL rows and does not perform authorization itself.

Does Discourse ACL support user-level grants?

Backend support for allowed_user_ids is partial: expansion, flattening, preloading, lookup helpers, matching scopes, and cleanup jobs handle user rows. However, the DAccessControl frontend component remains group-first and does not yet provide complete user ACL editing.

What is the difference between mandatory_acl and banned_acl in Discourse?

mandatory_acl defines grants that AccessControlListManager always injects before persisting, such as admins retaining manage. banned_acl defines grants the manager rejects outright, like anonymous users receiving edit, and DAccessControl hides those options in the UI.

Why does my ACL change prompt a loss warning in Discourse?

Targets defining loss_warning_permissions trigger AccessControlList::EvaluateModification when the current actor would lose a configured permission. The frontend posts the proposed ACL to /access-control/evaluate.json and shows the target-specific server translation for confirmation before saving.