Logo Check Access Control Model

Check Access Control Model

Cộng đồng
dykyi-roman
check-access-control-model

Analyzes PHP code for access control issues. Detects inline role checks, hardcoded permissions, mixed ACL/RBAC models, missing Voter/Policy pattern, and authorization logic in controllers.

Add to TypingMind

Tổng quan

Nhà phát hànhdykyi-roman
Kho mãawesome-claude-code
Tên kỹ năngcheck-access-control-model
Sao
98
Bản fork
25
Tệp đi kèm
Chỉ có hướng dẫn
Giấy phépMIT
Liên kết
  • Hướng dẫn bằng Markdown

    Tệp SKILL.md được mô hình tải khi cần, nên chỉ tốn token khi có yêu cầu thực sự phù hợp.

  • Dùng được với mọi LLM

    Kỹ năng AI dùng hướng dẫn viết bằng Markdown thay vì mã dành riêng cho một nhà cung cấp, nên dùng được với GPT, Claude, Gemini, Grok hoặc mô hình cục bộ.

  • Hướng dẫn có đủ mọi thứ cần thiết

    Mọi thứ mô hình cần đều nằm trong hướng dẫn — không có tệp bổ sung cần đồng bộ.

  • Mã nguồn mở

    Được dykyi-roman công bố trên GitHub. Hãy đọc các tệp nguồn trước khi cài đặt.

Cài đặt

Cài đặt kỹ năng AI Check Access Control Model trong TypingMind để dùng với bất kỳ LLM nào, hoặc thêm vào một tác nhân AI khác có thể đọc SKILL.md.

1

Cài đặt trong TypingMind

TypingMind cài đặt kỹ năng trực tiếp từ thư mục GitHub — đọc SKILL.md, đóng gói các tệp tài nguyên và lưu kết quả trên máy.

  1. Mở ứng dụng và vào Plugin → Kỹ năng.
  2. Chọn "Cài đặt từ GitHub".
  3. Dán URL của thư mục kỹ năng được hiển thị bên dưới rồi xác nhận.
    https://github.com/dykyi-roman/awesome-claude-code/tree/master/skills/check-access-control-model
  4. Bật kỹ năng trong từng cuộc trò chuyện mà bạn muốn sử dụng kỹ năng đó.
Plugin → Kỹ năng → Thêm kỹ năng → Từ URL GitHub, sau đó dán URL thư mục và nhấn Tiếp tục.
2

Cài đặt trong tác nhân AI khác

Bất kỳ tác nhân AI nào đọc được định dạng Agent Skills đều có thể dùng kỹ năng này — hãy sao chép thư mục vào thư mục kỹ năng của tác nhân AI đó.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/dykyi-roman/awesome-claude-code.git /tmp/awesome-claude-code
mkdir -p .claude/skills
cp -r /tmp/awesome-claude-code/skills/check-access-control-model .claude/skills/check-access-control-model
Khởi động lại Claude Code sau khi sao chép để ứng dụng nhận kỹ năng mới.

Sử dụng trong TypingMind

Bật Check Access Control Model trong bất kỳ cuộc trò chuyện nào trên TypingMind, mô hình sẽ tự xử lý phần còn lại. Tên và mô tả của kỹ năng nằm trong prompt hệ thống. Ngay khi có yêu cầu phù hợp, mô hình tự tải toàn bộ hướng dẫn — bạn không cần gọi thủ công và kỹ năng không tốn token cho đến khi thực sự được dùng.

Mô hình tự nạp Check Access Control Model ngay khi có yêu cầu phù hợp.

Dùng được với mọi mô hình AI

Kỹ năng AI là các hướng dẫn Markdown thuần túy, không phải mã dành riêng cho một nhà cung cấp, nên bạn có thể dùng Check Access Control Model với cả những mô hình khác ngoài mô hình ban đầu. Chỉ cần cài đặt một lần trong TypingMind rồi dùng với GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama hoặc mô hình cục bộ do bạn tự chạy — tất cả đều dùng khóa API của riêng bạn.

  • Chỉ tải khi cần

    Prompt hệ thống chỉ chứa tên và mô tả. Hướng dẫn được tải khi có yêu cầu phù hợp đầu tiên, nên khi kỹ năng chưa được dùng, bạn không tốn token cho phần hướng dẫn.

  • Đổi mô hình ngay trong cuộc trò chuyện

    Vì kỹ năng là hướng dẫn chứ không phải mã, việc đổi mô hình không làm kỹ năng ngừng hoạt động — mô hình tiếp theo vẫn đọc cùng tệp SKILL.md.

Hướng dẫn của kỹ năng

Đây là nội dung SKILL.md mà mô hình tải. Hãy đọc trước khi cài đặt — kỹ năng là những hướng dẫn mà mô hình của bạn sẽ làm theo.

Access Control Model Check

Analyze PHP code for access control anti-patterns that lead to inconsistent authorization, privilege escalation, and unmaintainable permission logic.

Detection Patterns

1. Inline Role Checks

php
<?php

declare(strict_types=1);

// BAD: Hardcoded role check scattered across code
final class ArticleController
{
    public function delete(Request $request, string $id): Response
    {
        if ($request->user()->role === 'admin') {
            $this->articleService->delete($id);
            return new Response(null, 204);
        }

        return new Response('Forbidden', 403);
    }
}

// BAD: String-based role comparison
if ($user->getRole() === 'editor' || $user->getRole() === 'admin') {
    // Allowed
}

// GOOD: Voter/Policy pattern
final class ArticleVoter extends Voter
{
    protected function supports(string $attribute, mixed $subject): bool
    {
        return $subject instanceof Article
            && in_array($attribute, ['VIEW', 'EDIT', 'DELETE'], true);
    }

    protected function voteOnAttribute(string $attribute, mixed $subject, TokenInterface $token): bool
    {
        $user = $token->getUser();

        return match ($attribute) {
            'DELETE' => $this->canDelete($user, $subject),
            'EDIT' => $this->canEdit($user, $subject),
            'VIEW' => true,
            default => false,
        };
    }

    private function canDelete(UserInterface $user, Article $article): bool
    {
        return $user->hasRole('ROLE_ADMIN')
            || $article->authorId()->equals($user->id());
    }

    private function canEdit(UserInterface $user, Article $article): bool
    {
        return $user->hasRole('ROLE_EDITOR')
            || $article->authorId()->equals($user->id());
    }
}

// Usage in controller
final class ArticleController
{
    public function delete(Request $request, string $id): Response
    {
        $article = $this->articleRepository->findOrFail(new ArticleId($id));
        $this->denyAccessUnlessGranted('DELETE', $article);

        $this->articleService->delete($article);

        return new Response(null, 204);
    }
}

2. Hardcoded Permission Strings

php
<?php

declare(strict_types=1);

// BAD: Magic permission strings everywhere
if ($user->hasPermission('manage_users')) { /* ... */ }
if ($user->hasPermission('edit_posts')) { /* ... */ }
if ($user->hasPermission('manage_users')) { /* ... */ } // Typo risk!

// GOOD: Permission enum
enum Permission: string
{
    case ManageUsers = 'manage_users';
    case EditPosts = 'edit_posts';
    case ViewReports = 'view_reports';
    case DeleteOrders = 'delete_orders';
}

// Usage
if ($user->hasPermission(Permission::ManageUsers)) { /* ... */ }

3. Mixed Authorization Models

php
<?php

declare(strict_types=1);

// BAD: Some endpoints use RBAC, others use ACL, others use nothing
final class UserController
{
    public function index(): Response
    {
        // RBAC-style
        if (!$this->security->isGranted('ROLE_ADMIN')) {
            throw new AccessDeniedHttpException();
        }
        return new Response($this->userService->list());
    }
}

final class OrderController
{
    public function show(string $id): Response
    {
        // ACL-style
        $order = $this->orderRepo->find($id);
        if ($order->userId() !== $this->getUser()->id()) {
            throw new AccessDeniedHttpException();
        }
        return new Response($order);
    }
}

final class ReportController
{
    public function index(): Response
    {
        // No authorization at all!
        return new Response($this->reportService->generate());
    }
}

// GOOD: Consistent Voter-based authorization across all controllers
// Each resource type has its own Voter
// All controllers use denyAccessUnlessGranted()

4. Authorization Logic in Controllers

php
<?php

declare(strict_types=1);

// BAD: Complex authorization logic in controller action
final class ProjectController
{
    public function update(Request $request, string $id): Response
    {
        $project = $this->projectRepo->find($id);
        $user = $request->user();

        // 15 lines of authorization logic in controller
        if ($user->role === 'admin') {
            // admin can do anything
        } elseif ($user->role === 'manager' && $project->teamId() === $user->teamId()) {
            // manager can edit own team projects
        } elseif ($project->ownerId() === $user->id()) {
            // owner can edit own project
        } else {
            return new Response('Forbidden', 403);
        }

        $this->projectService->update($project, $request->validated());

        return new Response($project);
    }
}

// GOOD: Authorization in middleware or Voter
#[IsGranted('EDIT', subject: 'project')]
final class ProjectController
{
    public function update(Request $request, #[MapEntity] Project $project): Response
    {
        $this->projectService->update($project, $request->validated());

        return new Response($project);
    }
}

5. Missing Deny-by-Default

php
<?php

declare(strict_types=1);

// BAD: Some routes have no authorization at all
// Routes file with no access control:
// Route::get('/admin/users', [AdminController::class, 'users']);
// Route::post('/admin/settings', [AdminController::class, 'updateSettings']);

// GOOD: Global middleware enforces deny-by-default
// security.yaml or middleware
// access_control:
//     - { path: ^/api/public, roles: PUBLIC_ACCESS }
//     - { path: ^/api, roles: IS_AUTHENTICATED_FULLY }
//     - { path: ^/admin, roles: ROLE_ADMIN }
//     - { path: ^/, roles: IS_AUTHENTICATED_FULLY }  # Deny-by-default

Grep Patterns

bash
# Inline role checks (string comparison)
Grep: "->role\s*===\s*['\"]|->getRole\(\)\s*===\s*['\"]|role\s*==\s*['\"]" --glob "**/*.php"

# Hardcoded permission strings (not enum)
Grep: "hasPermission\(['\"]|can\(['\"]|isAllowed\(['\"]" --glob "**/*.php"

# Authorization checks in controllers
Grep: "->role|->getRole|isAdmin|isManager|hasRole" --glob "**/*Controller*.php"
Grep: "->role|->getRole|isAdmin|isManager|hasRole" --glob "**/*Action*.php"

# Voter/Policy pattern presence
Grep: "extends Voter|extends Policy|implements VoterInterface" --glob "**/*.php"

# Security attributes/annotations
Grep: "#\[IsGranted|@IsGranted|@Security|denyAccessUnlessGranted" --glob "**/*.php"

# Missing authorization (controllers without security)
Grep: "class.*Controller" --glob "**/*Controller*.php"
Grep: "class.*Action" --glob "**/*Action*.php"

# Permission enum existence
Grep: "enum.*Permission|enum.*Role" --glob "**/*.php"

Severity Classification

PatternSeverity
Missing deny-by-default🔴 Critical
No authorization on admin endpoints🔴 Critical
Inline role checks with string comparison🟠 Major
Authorization logic in controllers🟠 Major
Hardcoded permission strings (no enum)🟠 Major
Mixed RBAC/ACL models🟡 Minor
Missing Voter/Policy for resource access🟡 Minor

Output Format

markdown
### Access Control Issue: [Brief Description]

**Severity:** 🔴/🟠/🟡
**Location:** `file.php:line`
**Type:** [Inline Check|Hardcoded Permission|Mixed Model|Controller Auth|No Auth]

**Issue:**
[Description of the access control anti-pattern]

**Risk:**
- Privilege escalation via inconsistent checks
- Forgotten authorization on new endpoints
- Permission logic impossible to audit

**Code:**
```php
// Problematic pattern

Fix:

php
// With proper access control

## When This Is Acceptable

- **Public API endpoints** -- Endpoints explicitly designed for unauthenticated access (e.g., login, registration, public data)
- **Internal microservice communication** -- Service-to-service calls behind network security where mutual TLS is used
- **CLI commands** -- Console commands that run with system-level privileges by design
- **Health check endpoints** -- /health, /ready, /live endpoints intended for load balancers

### False Positive Indicators
- Route is explicitly marked as public in security configuration
- Controller is behind a firewall rule that already enforces authentication
- Role check is inside a Voter or Policy class (correct location)

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

Kỹ năng AI Check Access Control Model làm được gì?

Analyzes PHP code for access control issues. Detects inline role checks, hardcoded permissions, mixed ACL/RBAC models, missing Voter/Policy pattern, and authorization logic in controllers.

Vì sao nên dùng Check Access Control Model trên TypingMind?

Vì bạn chỉ cần cài một lần rồi dùng với bất kỳ mô hình nào. Check Access Control Model là nội dung Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên cùng một kỹ năng có thể chạy trên GPT-5, Claude, Gemini, Grok hoặc mô hình trên thiết bị — và bạn có thể đổi mô hình ngay trong cuộc trò chuyện mà kỹ năng vẫn hoạt động. TypingMind dùng khóa API riêng của bạn, nên bạn thanh toán trực tiếp cho nhà cung cấp thay vì trả phí thuê bao theo suất người dùng, đồng thời kỹ năng và các cuộc trò chuyện vẫn nằm trong bộ lưu trữ của bạn.

Làm thế nào để cài Check Access Control Model trong TypingMind?

Mở Plugin → Kỹ năng → Cài đặt từ GitHub trong TypingMind rồi dán https://github.com/dykyi-roman/awesome-claude-code/tree/master/skills/check-access-control-model. TypingMind đọc tệp SKILL.md rồi cài đặt kỹ năng để bạn có thể bật cho từng cuộc trò chuyện.

Những mô hình AI nào có thể dùng Check Access Control Model?

Bất kỳ mô hình nào bạn kết nối trong TypingMind. Kỹ năng AI là các hướng dẫn bằng Markdown chứ không phải mã dành riêng cho từng nhà cung cấp, nên GPT, Claude, Gemini, Grok và các mô hình chạy trên thiết bị đều có thể tải kỹ năng này khi có yêu cầu phù hợp.

Có thể dùng Check Access Control Model với bao nhiêu mô hình AI?

Bao nhiêu cũng được. Miễn là mô hình hỗ trợ kỹ năng, bạn có thể dùng Check Access Control Model với mô hình đó — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama và nhiều mô hình khác — tất cả đều trên TypingMind với khóa API riêng của bạn.

Kỹ năng AI Check Access Control Model có miễn phí không?

Có. Kỹ năng này được dykyi-roman phát hành trên GitHub theo giấy phép MIT. Bạn chỉ trả tiền cho nhà cung cấp AI của mình theo số token đã dùng.

Kỹ năng AI là gì?

Kỹ năng AI là một gói hướng dẫn có thể tái sử dụng, chỉ cho mô hình AI cách thực hiện một tác vụ cụ thể. Kỹ năng tuân theo định dạng mở Agent Skills: một tệp SKILL.md chứa tên và mô tả, cùng các tập lệnh, mẫu hoặc tệp tham khảo mà mô hình có thể cần. Mô hình chỉ đọc hướng dẫn khi yêu cầu của bạn phù hợp với kỹ năng, nên kỹ năng đã cài đặt không phát sinh chi phí cho đến khi được sử dụng.

Kỹ năng AI khác gì với plugin hoặc máy chủ MCP?

Plugin hoặc máy chủ MCP cung cấp các công cụ mới mà mô hình có thể gọi. Khi mô hình gọi một công cụ, mã của công cụ đó chạy ở đâu đó và trả về kết quả. Còn kỹ năng AI cung cấp kiến thức và quy trình: cách tiếp cận tác vụ, các bước cần thực hiện và những tiêu chí mà kết quả cần đáp ứng. Kỹ năng chỉ là nội dung Markdown, nên không cần máy chủ, khóa API hay môi trường thực thi và hoạt động với mọi mô hình.

Xem tất cả

Tạo ngay không gian làm việc AI riêng

Đăng ký bản tin của chúng tôi để nhận thông báo về tính năng mới và các đợt tặng quà sắp tới 👇