access-control-best-practices

Implement RBAC and authorization patterns across platform-go API endpoints.

1|Updated Jul 16, 2025
One-click install
npx skills add https://github.com/linskybing/platform-go --skill access-control-best-practices
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: access-control-best-practices
Source: https://github.com/linskybing/platform-go/tree/main/.github/skills/access-control-best-practices
Command: npx skills add https://github.com/linskybing/platform-go --skill access-control-best-practices

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This skill provides structured, battle-tested RBAC and authorization patterns to ensure every API endpoint is protected with a consistent permission model across the platform-go project.

Core Features & Use Cases

  • Role-based authorization patterns (Admin, GroupAdmin, GroupManager, GroupMember, UserOrAdmin) and the corresponding middleware usage.
  • Resource-level authorization using extractors (FromIDParam, FromProjectIDInPayload) to validate access to a specific resource.
  • Migration and testing guidance, including evaluation of edge cases, audit logging, and error handling for secure endpoints.

Quick Start

Protect a route with GroupManager extractor and the corresponding middleware, e.g., route.PUT("/:id", authMiddleware.GroupManager(middleware.FromIDParam(repos.Project.GetGroupIDByProjectID)), handler)

Frequently Asked Questions about access-control-best-practices

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement RBAC authorization in a Go Gin API?

You implement RBAC authorization using role-based middleware extractors applied to Gin routes, mapping roles like Admin or GroupManager to endpoints for consistent permission validation.

How does resource-level access control work in Go APIs?

Resource-level access control uses middleware extractors like FromIDParam or FromProjectIDInPayload to fetch and validate group associations before authorizing endpoint access.

What is the best way to secure API endpoints with middleware in Go?

Securing API endpoints involves a standardized middleware security checklist enforcing global and resource-level RBAC patterns, plus audit logging to track authorization outcomes.

Can I use extractors to validate GroupManager permissions for a specific route?

You validate GroupManager permissions by wrapping handlers with auth middleware and passing extractors like FromIDParam to resolve group IDs dynamically for access control.

How do I test RBAC middleware edge cases in Go?

Testing RBAC middleware edge cases involves evaluating unauthorized access attempts, verifying audit logs, and checking error handling to ensure correct endpoint permission boundaries.

Does this RBAC approach support migration to new authorization patterns?

The RBAC approach includes migration guidance and reference implementations to transition existing endpoints to new authorization patterns while maintaining auditable access control.