Install any skill in seconds. Free to start, no credit card required.
Get Started Free →@delon/acl skill - Access Control List for role-based permissions and UI element visibility. For ng-events construction site progress tracking system.
.claude/skills/aiskillstore-delon-acl/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | 75% | 0% |
| case-05 | ✗→✓ | ▲ Improved | 99% | 0% |
| case-09 | ✗→✓ | ▲ Improved | 208% | 0% |
| case-10 | ✗→✓ | ▲ Improved | 125% | 0% |
| case-14 | ✗→✓ | ▲ Improved | 129% | 0% |
Trigger patterns: "ACL", "permission", "role", "access control", "@delon/acl", "can", "ability"
@delon/acl provides a role-based access control (RBAC) system for ng-alain applications, controlling UI element visibility and feature access based on user roles and permissions.
Package: @delon/acl@20.1.0 Integrated with: @delon/auth for authentication
typescriptimport { inject } from '@angular/core'; import { ACLService } from '@delon/acl'; @Component({ selector: 'app-dashboard', standalone: true }) export class DashboardComponent { private aclService = inject(ACLService); ngOnInit(): void { // Set user roles and permissions this.aclService.setRole(['admin', 'user']); this.aclService.setAbility(['task:create', 'task:edit', 'task:delete']); // Set full ACL configuration this.aclService.set({ role: ['admin'], ability: ['task:create', 'task:edit'], mode: 'oneOf' // 'allOf' or 'oneOf' }); } canEditTask(): boolean { return this.aclService.can('task:edit'); } isAdmin(): boolean { return this.aclService.can({ role: ['admin'] }); } }
typescriptimport { ACLIfDirective } from '@delon/acl'; @Component({ imports: [ACLIfDirective], template: ` <!-- Show only if user has admin role --> <button *aclIf="'admin'" nz-button nzType="primary"> 管理設定 </button> <!-- Show only if user has task:create ability --> <button *aclIf="'task:create'" nz-button> 建立任務 </button> <!-- Complex condition: admin OR task:delete permission --> <button *aclIf="deletePermission" nz-button nzDanger> 刪除 </button> ` }) export class TaskListComponent { deletePermission = { role: ['admin'], ability: ['task:delete'], mode: 'oneOf' }; }
typescript@Component({ template: ` @if (canCreate()) { <button nz-button (click)="createTask()"> 建立任務 </button> } @if (isAdmin()) { <nz-card> <h3>管理員面板</h3> <!-- admin-only content --> </nz-card> } ` }) export class DashboardComponent { private aclService = inject(ACLService); canCreate = signal(this.aclService.can('task:create')); isAdmin = signal(this.aclService.can({ role: ['admin'] })); }
typescriptimport { inject } from '@angular/core'; import { CanActivateFn } from '@angular/router'; import { ACLService } from '@delon/acl'; import { Router } from '@angular/router'; // Role-based guard export const adminGuard: CanActivateFn = () => { const aclService = inject(ACLService); const router = inject(Router); if (aclService.can({ role: ['admin'] })) { return true; } return router.parseUrl('/403'); }; // Ability-based guard export const taskCreateGuard: CanActivateFn = () => { const aclService = inject(ACLService); const router = inject(Router); if (aclService.can('task:create')) { return true; } return router.parseUrl('/403'); }; // Complex permission guard export const blueprintEditGuard: CanActivateFn = () => { const aclService = inject(ACLService); const router = inject(Router); const canEdit = aclService.can({ role: ['admin', 'owner'], ability: ['blueprint:edit'], mode: 'oneOf' }); return canEdit || router.parseUrl('/403'); };
Route Configuration:
typescriptimport { Routes } from '@angular/router'; export const routes: Routes = [ { path: 'admin', canActivate: [adminGuard], loadComponent: () => import('./admin/admin.component') }, { path: 'tasks/create', canActivate: [taskCreateGuard], loadComponent: () => import('./tasks/create.component') }, { path: 'blueprints/:id/edit', canActivate: [blueprintEditGuard], loadComponent: () => import('./blueprints/edit.component') } ];
typescriptimport { Injectable, inject } from '@angular/core'; import { ACLService } from '@delon/acl'; import { AuthService } from '@core/services/auth.service'; import { BlueprintMemberRepository } from '@core/data-access/blueprint-member.repository'; /** * ng-events(GigHub) permission format: * - Roles: 'owner', 'admin', 'member', 'viewer' * - Abilities: 'module:action' format * Examples: 'task:create', 'task:edit', 'task:delete' * 'blueprint:edit', 'member:invite' */ @Injectable({ providedIn: 'root' }) export class PermissionService { private aclService = inject(ACLService); private authService = inject(AuthService); private memberRepo = inject(BlueprintMemberRepository); /** * Initialize permissions for a blueprint */ async initBlueprintPermissions(blueprintId: string): Promise<void> { const userId = this.authService.currentUserId(); if (!userId) { this.aclService.set({ role: [], ability: [] }); return; } // Get user's membership const member = await this.memberRepo.findByUserAndBlueprint( userId, blueprintId ); if (!member || member.status !== 'active') { this.aclService.set({ role: [], ability: [] }); return; } // Set roles and permissions this.aclService.set({ role: [member.role], ability: member.permissions || [], mode: 'oneOf' }); } /** * Check if user can perform action */ can(ability: string): boolean { return this.aclService.can(ability); } /** * Check if user has role */ hasRole(role: string | string[]): boolean { return this.aclService.can({ role: Array.isArray(role) ? role : [role] }); } /** * Check if user can edit task */ canEditTask(task: Task): boolean { // Owner or admin can always edit if (this.hasRole(['owner', 'admin'])) { return true; } // Member can edit if they have permission AND are assigned return this.can('task:edit') && task.assignedTo === this.authService.currentUserId(); } /** * Check if user can delete task */ canDeleteTask(): boolean { return this.hasRole(['owner', 'admin']) || this.can('task:delete'); } }
typescriptimport { Component, signal, computed, inject, OnInit } from '@angular/core'; import { ActivatedRoute } from '@angular/router'; import { PermissionService } from '@core/services/permission.service'; import { TaskService } from '@core/services/task.service'; import { ACLIfDirective } from '@delon/acl'; @Component({ selector: 'app-task-detail', standalone: true, imports: [ACLIfDirective], template: ` <nz-card> <h2>{{ task()?.title }}</h2> <!-- Show edit button if user can edit --> @if (canEdit()) { <button nz-button (click)="editTask()"> 編輯任務 </button> } <!-- Show delete button if user can delete --> @if (canDelete()) { <button nz-button nzDanger (click)="deleteTask()"> 刪除任務 </button> } <!-- Alternative: Using *aclIf directive --> <button *aclIf="'task:edit'" nz-button> 編輯 </button> <!-- Show admin panel if user is owner/admin --> @if (isOwnerOrAdmin()) { <nz-card> <h3>管理面板</h3> <!-- admin features --> </nz-card> } </nz-card> ` }) export class TaskDetailComponent implements OnInit { private route = inject(ActivatedRoute); private taskService = inject(TaskService); private permissionService = inject(PermissionService); task = signal<Task | null>(null); canEdit = computed(() => { const t = this.task(); return t ? this.permissionService.canEditTask(t) : false; }); canDelete = computed(() => this.permissionService.canDeleteTask() ); isOwnerOrAdmin = computed(() => this.permissionService.hasRole(['owner', 'admin']) ); async ngOnInit(): Promise<void> { const taskId = this.route.snapshot.params['id']; const blueprintId = this.route.snapshot.params['blueprintId']; // Initialize permissions for this blueprint await this.permissionService.initBlueprintPermissions(blueprintId); // Load task const task = await this.taskService.getTask(taskId); this.task.set(task); } editTask(): void { // Implementation } deleteTask(): void { // Implementation } }
✅ DO: Initialize in app initialization or route resolver
typescript// app.config.ts export const appConfig: ApplicationConfig = { providers: [ provideZoneChangeDetection({ eventCoalescing: true }), provideRouter(routes), { provide: APP_INITIALIZER, useFactory: (acl: ACLService, auth: AuthService) => () => { // Initialize ACL after auth return auth.getCurrentUser().then(user => { if (user) { acl.set({ role: [user.role], ability: user.permissions }); } }); }, deps: [ACLService, AuthService], multi: true } ] };
✅ DO: Create reactive permission checks
typescriptcanCreate = computed(() => this.aclService.can('task:create')); isAdmin = computed(() => this.aclService.can({ role: ['admin'] }));
✅ DO: Use ACL for UI + Firestore Security Rules for data
typescript// UI: Hide button if no permission @if (permissionService.can('task:delete')) { <button (click)="delete()">刪除</button> } // Firestore Security Rules: Enforce permission match /tasks/{taskId} { allow delete: if isBlueprintMember(resource.data.blueprintId) && hasPermission(resource.data.blueprintId, 'task:delete'); }
❌ Hardcoding Permissions in Components:
typescriptif (user.role === 'admin') { /* ... */ }
✅ Use ACL Service:
typescriptif (this.aclService.can({ role: ['admin'] })) { /* ... */ }
❌ Only Client-Side Permission Checks:
typescript// UI only - insecure! @if (canDelete()) { <button (click)="delete()">刪除</button> }
✅ Client + Server Validation:
typescript// UI check @if (canDelete()) { <button (click)="delete()">刪除</button> } // Firestore Security Rules allow delete: if hasPermission('task:delete');
.github/instructions/ng-ng-events(GigHub)-architecture.instructions.md - Permission architectureVersion: 1.0 Created: 2025-12-25 Maintainer: ng-events(GigHub) Development Team
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→pass | 17,032 | 12,074 | -29% | 1 | 1 | 0% | 3,269 | 5,708 | +75% | 0 | 0 | — |
case-02 | pass→pass | 15,661 | 14,637 | -7% | 1 | 1 | 0% | 3,099 | 6,223 | +101% | 0 | 0 | — |
case-03 | pass→pass | 7,232 | 5,792 | -20% | 1 | 1 | 0% | 1,382 | 4,306 | +212% | 0 | 0 | — |
case-04 | fail→fail | 11,250 | 8,588 | -24% | 1 | 1 | 0% | 1,682 | 4,823 | +187% | 0 | 0 | — |
case-05 | fail→pass | 11,674 | 5,861 | -50% | 1 | 1 | 0% | 2,220 | 4,409 | +99% | 0 | 0 | — |
case-06 | fail→fail | 7,719 | 5,909 | -23% | 1 | 1 | 0% | 1,317 | 4,301 | +227% | 0 | 0 | — |
case-07 | pass→pass | 11,103 | 9,942 | -10% | 1 | 1 | 0% | 2,066 | 5,127 | +148% | 0 | 0 | — |
case-08 | pass→pass | 13,389 | 11,266 | -16% | 1 | 1 | 0% | 2,417 | 5,357 | +122% | 0 | 0 | — |
case-09 | fail→pass | 10,356 | 10,305 | -0% | 1 | 1 | 0% | 1,574 | 4,852 | +208% | 0 | 0 | — |
case-10 | fail→pass | 11,997 | 6,164 | -49% | 1 | 1 | 0% | 1,972 | 4,444 | +125% | 0 | 0 | — |
case-11 | pass→pass | 12,644 | 11,807 | -7% | 1 | 1 | 0% | 2,173 | 5,270 | +143% | 0 | 0 | — |
case-12 | pass→pass | 13,510 | 8,604 | -36% | 1 | 1 | 0% | 2,213 | 4,744 | +114% | 0 | 0 | — |
case-13 | pass→pass | 6,965 | 5,430 | -22% | 1 | 1 | 0% | 1,257 | 4,203 | +234% | 0 | 0 | — |
case-14 | fail→pass | 16,576 | 12,720 | -23% | 1 | 1 | 0% | 2,470 | 5,645 | +129% | 0 | 0 | — |
case-15 | pass→pass | 13,528 | 14,861 | +10% | 1 | 1 | 0% | 2,218 | 5,550 | +150% | 0 | 0 | — |
case-16 | pass→pass | 8,944 | 5,175 | -42% | 1 | 1 | 0% | 1,455 | 4,133 | +184% | 0 | 0 | — |
case-17 | pass→pass | 5,330 | 3,502 | -34% | 1 | 1 | 0% | 798 | 3,869 | +385% | 0 | 0 | — |
case-18 | pass→pass | 6,912 | 4,260 | -38% | 1 | 1 | 0% | 1,060 | 3,954 | +273% | 0 | 0 | — |
case-19 | pass→pass | 10,413 | 20,218 | +94% | 1 | 1 | 0% | 2,054 | 5,719 | +178% | 0 | 0 | — |
case-20 | pass→pass | 10,887 | 6,470 | -41% | 1 | 1 | 0% | 1,934 | 4,491 | +132% | 0 | 0 | — |
case-21 | pass→pass | 8,411 | 10,791 | +28% | 1 | 1 | 0% | 1,544 | 4,610 | +199% | 0 | 0 | — |
case-22 | pass→pass | 14,267 | 14,317 | +0% | 1 | 1 | 0% | 2,751 | 5,863 | +113% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 22 cases were attempted. The headline lift of +23 percentage points is the difference between those two pass rates over the 22 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.