返回 Skill 列表
extension
分类: 开发与工程无需 API Key

libpolicy

libpolicy - 用于访问控制的策略引擎。PolicyIndex存储并评估授权策略。createPolicyIndex工厂从存储中加载策略。计划集成OPA-WASM以进行复杂的策略评估。可用于访问控制、授权决策和资源权限管理。

person作者: jakexiaohubgithub

libpolicy Skill

When to Use

  • Implementing access control for resources
  • Evaluating authorization policies
  • Managing permissions in multi-tenant systems
  • Building role-based access control (RBAC)

Key Concepts

PolicyIndex: Stores policies and evaluates access requests against them.

Policy evaluation: Determines if an actor can perform an action on a resource based on defined policies.

Usage Patterns

Pattern 1: Evaluate access

import { createPolicyIndex } from "@copilot-ld/libpolicy";

const index = await createPolicyIndex(storage);
const allowed = await index.evaluate({
  actor: "user:123",
  resource: "document:456",
  action: "read",
});

Pattern 2: Load policies

const index = await createPolicyIndex(storage);
await index.load("policies/"); // Load from directory

Integration

Used by ResourceIndex for access control. Policies stored in data/policies/.