Chuyển đến nội dung
Skillpedia
Website và giao diện (frontend)8.1k · #12575

webiny-admin-permissions

Skill này làm gì

Skill này hướng dẫn AI của bạn khi thêm kiểm soát quyền vào giao diện quản trị Webiny. Dành cho lập trình viên cần giới hạn những gì người dùng thấy hoặc làm được trong bảng quản trị.

Khi nào nên dùng

  • ✓Khi bạn cần thêm thiết lập quyền vào một tính năng quản trị Webiny.
  • ✓Khi bạn muốn form quyền được sinh từ một schema thay vì viết tay.
  • ✓Khi một phần màn hình quản trị phải hiện hoặc ẩn tùy theo quyền của người dùng.

Liên kết skill

https://github.com/webiny/webiny-js/blob/next/skills/user-skills/admin/admin-permissions/SKILL.md

Sao chép rồi dán vào AI của bạn (Claude, ChatGPT hoặc Cursor) và nhờ nó làm theo hướng dẫn.

Cách dùng

Cách dễ nhất: sao chép tin nhắn và dán vào AI của bạn. AI sẽ đọc skill và làm theo hướng dẫn.

Tin nhắn có sẵn để dán

Hãy dùng skill này để giúp tôi: https://github.com/webiny/webiny-js/blob/next/skills/user-skills/admin/admin-permissions/SKILL.md Đọc tệp SKILL.md tại liên kết đó và làm theo hướng dẫn cho việc của tôi.
Bạn muốn AI tự tìm những skill như thế này?Cài MCP Skillpedia miễn phí: chỉ một dòng, và AI sẽ tìm trong 15.000+ skill trước mỗi việc.Cài đặt trong 1 phút →

Ví dụ cách nhờ AI

“Thêm kiểm soát quyền cho phần sản phẩm trong quản trị Webiny, với quy tắc riêng cho chỉnh sửa và nhập dữ liệu.”

5 skill mới mỗi tuần. Đọc chỉ 1 phút.

Cách hoạt động

Skill giải thích cách định nghĩa một schema quyền, từ đó sinh ra form quyền. Nó cũng bao phủ các kiểm tra quyền có thể inject và component để ẩn hoặc hiện các phần giao diện.

Nội dung kỹ thuật (SKILL.md gốc)

Lấy nguyên văn từ GitHub, do tác giả viết bằng tiếng Anh.

Admin Permissions

Overview

Permissions follow three layers: domain (schema), features (DI artifacts + registration), and presentation (hooks, components, UI config). The framework auto-generates the permission UI from a schema and provides injectable permission checking via the DI container.

Layer 1: Domain — Permission Schema

Define the schema in src/domain/permissionsSchema.ts:

import { createPermissionSchema } from "webiny/admin/security";

export const SM_PERMISSIONS_SCHEMA = createPermissionSchema({
  prefix: "sm",
  fullAccess: true,
  entities: [
    {
      id: "product",
      title: "Products",
      permission: "sm.product",
      scopes: ["full", "own"],
      actions: [
        { name: "rwd" },
        { name: "pw" },
        { name: "import", label: "Import products" },
        { name: "export", label: "Export products" }
      ]
    },
    {
      id: "category",
      title: "Categories",
      permission: "sm.category",
      scopes: ["full"],
      actions: [{ name: "rwd" }]
    },
    {
      id: "settings",
      title: "Settings",
      permission: "sm.settings",
      scopes: ["full"]
    }
  ]
});

Schema Reference

Field Type Required Description
prefix string Yes Permission prefix (e.g., "sm")
fullAccess true | object Yes true for standard full access. Pass an object with custom boolean flags for full-access extras (e.g., { canForceUnlock: true }).
readOnlyAccess boolean No Whether to show a "Read-only access" option
entities EntityDefinition[] No Entity definitions. Omit for binary full/no access.

Entity Definition

Field Type Required Description
id string Yes Unique identifier for form field naming
title string No Display title. Falls back to id.
permission string Yes Permission name emitted (e.g., "sm.product")
scopes ("full" | "own")[] Yes Available access scopes
actions ActionDefinition[] No Actions on this entity
dependsOn { entity: string; requires: string } No Dependency on another entity

Actions

  • { name: "rwd" } — Read/Write/Delete select dropdown. Auto-set to "rwd" when scope is "own".
  • { name: "pw" } — Publish/Unpublish checkbox group.
  • { name: "custom", label: "Label" } — Custom boolean flag.

Entity Dependencies

Child entities can depend on a parent. If the parent lacks the required action, the child is pruned from output. "own" scope cascades to dependents.

{
    id: "review",
    permission: "sm.review",
    scopes: ["full", "own"],
    actions: [{ name: "rwd" }],
    dependsOn: { entity: "product", requires: "r" }
}

Simple Apps (No Entities)

Omit entities for binary full/no access:

export const MA_PERMISSIONS_SCHEMA = createPermissionSchema({
  prefix: "ma",
  fullAccess: true
});

Layer 2: Features — DI Artifacts + Registration

Abstraction (src/features/permissions/abstractions.ts)

import { createPermissionsAbstraction } from "webiny/admin/security";
import type { Permissions } from "webiny/admin/security";
import { SM_PERMISSIONS_SCHEMA } from "~/domain/permissionsSchema.js";

export const SmPermissions = createPermissionsAbstraction(SM_PERMISSIONS_SCHEMA);

export namespac
Câu hỏi thường gặp

Schema quyền làm gì?

Nó định nghĩa các entity, hành động và phạm vi của chúng, và form quản trị được sinh từ đó.

Quyền được kiểm tra trong mã thế nào?

Skill mô tả các kiểm tra quyền có thể inject và một hook có kiểu cho component.

Nó có bao gồm phía máy chủ không?

Skill tập trung vào giao diện người dùng quản trị và kiểm tra quyền ở tầng đó.

Chi tiết

Mô tả gốc của tác giả

Admin-side permission UI registration and DI-backed permission checking. Use this skill when adding permission controls to the admin UI — schema-based auto-generated forms, injectable permissions via createPermissionsAbstraction/ createPermissionsFeature, typed hooks (createUsePermissions), the HasPermission component (createHasPermission), and the Security.Permissions component props. Covers both simple apps and complex multi-entity permission schemas.

repo: webiny/webiny-js

Độ phổ biến

Sao GitHub
8.1k
Vị trí xếp hạng
#12575
Giấy phép
—
Cập nhật
2/11/2026

Skill này có hữu ích không?

0

Đăng nhập để bình chọn.

Bình luận

  • …

Thêm skill từ kho mã này

Skill tương tự