← 返回
安全合规 中文

Authorization

Build secure access control with RBAC, ABAC, permissions, policies, and scope-based authorization.
通过 RBAC、ABAC、权限、策略及基于范围的授权构建安全访问控制。
ivangdavila
安全合规 clawhub v1.0.0 1 版本 99901.8 Key: 无需
★ 2
Stars
📥 977
下载
💾 10
安装
1
版本
#latest

概述

When to Use

User needs to control what actions users can perform. Agent handles permission design, role hierarchies, policy evaluation, and access control middleware.

Quick Reference

TopicFile
-------------
RBAC vs ABAC comparisonmodels.md
Implementation patternspatterns.md
Framework middlewaremiddleware.md

Core Rules

1. Auth ≠ Authorization

  • Authentication: Who you are (login, OAuth, tokens)
  • Authorization: What you can do (permissions, roles, policies)
  • Never mix concerns — auth happens BEFORE authorization

2. Principle of Least Privilege

  • Default deny — explicit grants only
  • Users get minimum permissions for their job
  • Audit permissions periodically (revoke unused)
  • Temporary elevation over permanent grants

3. Choose the Right Model

ModelBest ForComplexity
-----------------------------
ACLSimple resource ownershipLow
RBACOrganizational hierarchiesMedium
ABACDynamic context-based rulesHigh
ReBACSocial graphs, sharingHigh

Start simple → evolve when needed.

4. Role Design Patterns

  • Roles represent jobs, not permissions
  • Max 3 inheritance levels (admin → manager → user)
  • Avoid role explosion — combine with ABAC for edge cases
  • Document role definitions (what can this role DO?)

5. Permission Naming

resource:action:scope
documents:write:own     ← Can edit own documents
documents:write:team    ← Can edit team documents
documents:delete:all    ← Can delete any document

Consistent naming prevents ambiguity.

6. Policy Evaluation Order

  1. Explicit deny → always wins
  2. Explicit allow → checked second
  3. No match → default deny
  4. Log all denials for debugging

7. Never Hardcode

// ❌ Bad — hardcoded role check
if (user.role === 'admin') { ... }

// ✅ Good — permission check
if (can(user, 'settings:update')) { ... }

Roles change. Permissions are stable.

Common Traps

  • Checking roles instead of permissions → brittle when roles change
  • OR logic in permissions → "can edit OR is admin" creates backdoors
  • Caching permissions too long → stale grants after role changes
  • Frontend-only checks → always verify server-side
  • God roles → split "admin" into specific permission sets
  • Circular inheritance → A inherits B inherits A crashes system

Security & Privacy

Data that stays local:

  • All documentation and patterns are reference material
  • No data collection or external requests

This skill does NOT:

  • Access your codebase automatically
  • Make network requests
  • Store any user data

Feedback

  • If useful: clawhub star authorization
  • Stay updated: clawhub sync

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-03-29 08:00 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

security-compliance

MoltGuard - Security & Antivirus & Guardrails

thomaslwang
MoltGuard — OpenClaw 安全守卫,由 OpenGuardrails 提供。安装 MoltGuard,保护您和您的用户免受提示注入、数据泄露和恶意攻击。
★ 116 📥 30,720
productivity

Word / DOCX

ivangdavila
创建、检查和编辑 Microsoft Word 文档及 DOCX 文件,支持样式、编号、修订记录、表格、分节符及兼容性检查等功能。
★ 438 📥 147,664
security-compliance

Skill Vetter

spclaudehome
AI智能体技能安全预审工具。安装ClawdHub、GitHub等来源技能前,检查风险信号、权限范围及可疑模式。
★ 1,215 📥 266,540