permissions

Implements authentication and authorization in Spring Boot services using a Strategy and Handler pattern.

Updated Jun 25, 2026
One-click install
npx skills add https://github.com/oriddd/ai-toolkit --skill permissions-oriddd
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: permissions
Source: https://github.com/oriddd/ai-toolkit/tree/main/copilot/public/skills/permissions
Command: npx skills add https://github.com/oriddd/ai-toolkit --skill permissions-oriddd

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Adding per-resource authorization to a Spring Boot microservice often leads to tangled if/else logic scattered across controllers and handlers. This Skill scaffolds a clean, pluggable authorization layer that dispatches permission checks by caller type, so new caller contexts can be added without modifying existing code. ## Core Features & Use Cases - Pluggable Strategy + Handler + Registry architecture: Generates a PermissionsHandler, PermissionsRegistry, CallerContextResolver, and per-context PermissionsCheckStrategy components wired via Spring list injection. - Vendor-neutral plug-points: Ships defaults for Spring Security's SecurityContextHolder and an abstract ResourceAuthorizationSource, letting teams plug in their own token shapes and authorization back-ends. - Complete test and validation guidance: Includes required unit test cases, component test wiring with a mock handler, and an end-to-end validation matrix covering 401/403/2xx scenarios. - Use Case: When creating a new microservice that exposes user-facing data, invoke this Skill to generate the full permission package, configure allowed OAuth2 scopes for service accounts, and enforce per-resource checks inside every operation. ## Quick Start Ask the AI to apply the permissions skill to scaffold an authorization layer for your Spring Boot service, specifying your base package, accepted caller contexts, and resource identifier.

Frequently Asked Questions about permissions

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

FAQPage Schema
How do I add authorization to a Spring Boot microservice?

Use a Strategy plus Handler pattern: a PermissionsHandler resolves the caller context, looks up a matching PermissionsCheckStrategy from a registry, and delegates the check. This Skill generates all components, configuration, and tests for that structure.

How do I support multiple caller types like users and service accounts in Spring Security?

Define a CallerContext enum and one strategy per context, such as ScopeBasedPermissionsCheck for service accounts and ResourcePermissionsCheck for users. Spring injects all strategy beans into a registry, so adding a new caller type only requires one new component and enum value.

Does this work with OAuth2 resource servers and JWT tokens?

Yes, the Skill supports spring-boot-starter-oauth2-resource-server for validating OAuth2 tokens. Scope checks read authorities from the current Authentication and strip the SCOPE_ prefix that Spring Security adds, while token parsing remains a pluggable resolver concern.

Where should permission checks be placed, controller or service layer?

Place the permissionsHandler.handle call inside the operation (use case) layer, as the first call after parameter validation, never in the controller. The controller advice only maps the resulting ForbiddenException to an HTTP 403 status.

Why does my permission check throw UNRECOGNIZED_CALLER_CONTEXT?

This happens when the resolved CallerContext has no registered strategy. Always provide an explicit strategy for every accepted context, including a documented NoOpPermissionsCheck for trusted BASIC_AUTH callers, so the dispatcher never fails.