controller-roles

Map roles to API endpoint handlers with fallback to lower-privilege handlers.

Updated Aug 23, 2026
One-click install
npx skills add https://github.com/griffnb/claude-plugins --skill controller-roles
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: controller-roles
Source: https://github.com/griffnb/claude-plugins/tree/main/plugins/backend/skills/controller-roles
Command: npx skills add https://github.com/griffnb/claude-plugins --skill controller-roles

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

API endpoints often lack consistent and secure access control, leading to privilege leaks and duplicated authorization logic across routes.

Core Features & Use Cases

  • Role-based routing for handlers: map roles to specific request handlers with automatic fallbacks to lower-privilege permissions.
  • Session-aware authorization: automatically extracts and uses the user session to enforce access rules.
  • Reusable patterns for admin and authenticated endpoints: provides templates for admin, read-admin, and public endpoints with predictable behavior.

Quick Start

Configure your API endpoints to use RoleHandler with a map of roles to handlers to enforce proper access control.

Frequently Asked Questions about controller-roles

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

FAQPage Schema
How do I enforce role-based access control on API endpoints in Golang?

Role-based access control for API endpoints is enforced by mapping specific user roles to designated handler functions, applying session extraction and role lookup to resolve the highest-privilege handler for each request.

How does middleware handle unauthorized API requests with RBAC?

Unauthorized API requests trigger a 401 Unauthorized fallback when session extraction or role lookup fails to match a valid handler, ensuring safe access by automatically falling back to lower-privilege handlers as needed.

Can I apply role-based routing for admin, read-admin, and public endpoints?

Role-based routing supports admin, read-admin, any authorized user, and unauthenticated requests by mapping each role tier to specific handler functions with automatic fallbacks to lower-privilege permissions.

What is the best way to prevent privilege leaks in API authorization logic?

Preventing privilege leaks requires consistent role-based access control that maps roles to handler functions with predictable fallbacks, eliminating duplicated authorization logic across routes.

Does this RBAC approach work with existing session extraction middleware?

Role-based access control integrates with session-aware authorization by automatically extracting and using the existing user session to enforce access rules before resolving the appropriate handler.

When should I use fallback handlers in role-based API authorization?

Fallback handlers apply when higher-privilege role checks fail, automatically routing requests to lower-privilege handlers to maintain safe access and prevent complete authorization failures.