springboot-security

Codify Spring Boot security best practices for authentication, authorization, and validation.

6|Updated Mar 25, 2023
One-click install
npx skills add https://github.com/songkg7/dotfiles --skill springboot-security-songkg7
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: springboot-security
Source: https://github.com/songkg7/dotfiles/tree/main/dot_claude/skills/springboot-security
Command: npx skills add https://github.com/songkg7/dotfiles --skill springboot-security-songkg7

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides a practical guide for implementing consistent Spring Boot security practices across authentication, authorization, input validation, CSRF, secrets, and security headers to protect services.

Core Features & Use Cases

  • Authentication best practices: stateless tokens (JWT or opaque) with revocation, secure cookies, and token validation.
  • Authorization and access control: method security with @EnableMethodSecurity and @PreAuthorize checks.
  • Data protection and validation: input validation, sanitization, and secure configuration for sensitive data.
  • Security posture: CSRF decisions, secure headers, and safe handling of secrets and dependencies.
  • Use Case: apply these patterns to a new REST service to prevent lax security and enforce least privilege.

Quick Start

Initialize your Spring Boot project with security-enabled dependencies, enable method security, and apply standard token-based authentication and CSRF decisions according to your app type.

Frequently Asked Questions about springboot-security

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

FAQPage Schema
How do I implement token-based authentication in Spring Boot?

Token-based authentication in Spring Boot uses stateless sessions with JWT or opaque tokens, secure cookies, and revocation lists. You configure token validation filters to intercept requests and verify token integrity before granting access to protected resources.

What's the best way to enforce authorization in Spring Boot REST services?

The best way to enforce authorization in Spring Boot REST services is enabling @EnableMethodSecurity and applying @PreAuthorize checks on controller methods. This enforces least privilege by verifying user roles and permissions before method execution.

Do I need CSRF protection for stateless Spring Boot APIs?

CSRF protection decisions for stateless Spring Boot APIs depend on your application type. Stateless APIs using token-based authentication typically disable CSRF, while web applications with session cookies must enable it to prevent cross-site request forgery attacks.

How do you handle secrets and security headers in Spring Boot?

Handling secrets and security headers in Spring Boot requires safe secret management configuration and standard security headers. You store secrets in environment variables or vaults instead of code and configure headers like Content-Security-Policy to harden the application posture.

Can I use @PreAuthorize with microservices for access control?

Yes, @PreAuthorize works with microservices for access control by enabling @EnableMethodSecurity across individual services. Token validation is performed at the gateway or service level, allowing each microservice to independently enforce method-level authorization.