security-auth-patterns

Centralize Spring Security, JWT validation, and RBAC for backend endpoints.

1|3|Updated Mar 4, 2026
One-click install
npx skills add https://github.com/rizwan2004cs/AI-Donor-Matcher-Backend --skill security-auth-patterns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: security-auth-patterns
Source: https://github.com/rizwan2004cs/AI-Donor-Matcher-Backend/tree/main/docs/skills/security-auth-patterns
Command: npx skills add https://github.com/rizwan2004cs/AI-Donor-Matcher-Backend --skill security-auth-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Inconsistent and insecure access control in backend services is addressed by providing centralized security patterns for Spring Security, JWT authentication, and role-based access control (RBAC) tailored for the AI Donor Matcher backend.

Core Features & Use Cases

  • Centralized SecurityConfig rules and JWT validation flow to ensure consistent authorization across endpoints.
  • Clear role mapping (DONOR, NGO, ADMIN) with enforcement of permissions on API surfaces.
  • Helpers and guidance for extracting authenticated user details from the SecurityContext within controllers and services.

Quick Start

Configure SecurityConfig and JwtFilter to protect new endpoints by enforcing JWT authentication and role-based access control.

Frequently Asked Questions about security-auth-patterns

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

FAQPage Schema
How do I configure Spring Security with JWT and RBAC for backend endpoints?

Configure Spring Security with JWT and RBAC by centralizing SecurityConfig rules and JwtFilter to enforce JWT authentication and role-based access control across backend endpoints. This ensures consistent authorization for protected API routes.

What is the best way to extract authenticated user details from SecurityContext in Spring controllers?

Extract authenticated user details from SecurityContext using provided helpers and guidance within controllers and services. This centralizes user context extraction to avoid inconsistent auth handling across backend services.

How do I enforce role-based access control for specific user roles like DONOR, NGO, and ADMIN?

Enforce role-based access control for DONOR, NGO, and ADMIN roles by applying clear role mapping with permission enforcement on API surfaces. SecurityConfig rules define which endpoints require specific roles for access.

Does this JWT validation flow work with existing Spring Security configurations?

The JWT validation flow integrates with Spring Security by configuring JwtFilter alongside SecurityConfig. It centralizes authentication handling to replace inconsistent access controls while maintaining compatibility with standard Spring Security setups.

Why does JWT authentication fail when adding new endpoints to a Spring Security backend?

JWT authentication fails on new endpoints when SecurityConfig rules and JwtFilter are not configured to protect them. Centralizing security patterns ensures consistent JWT validation and role-based access enforcement across all API surfaces.