Springboot Security logo

Springboot Security

CommunityPopular
xu-xiang
springboot-security

Spring Boot 服务的 Spring Security 身份验证/授权、验证、CSRF、密钥、响应头、速率限制和依赖项安全最佳实践。

Overview

Publisherxu-xiang
Repositoryeverything-claude-code-zh
Skill namespringboot-security
Stars
1.9K
Forks
318
Bundled files
Instructions only
LicenseMIT
Links
  • Markdown instructions

    A SKILL.md file the model loads on demand, so it only costs tokens when a request actually matches.

  • Works with any LLM

    AI skills are plain Markdown, not provider-specific code, so this works with GPT, Claude, Gemini, Grok, or a local model.

  • Self-contained

    Everything the model needs lives in the instructions — no extra files to sync.

  • Open source

    Published by xu-xiang on GitHub. Read the source before you install it.

Installation

Install the Springboot Security AI skill in TypingMind to use it with any LLM, or drop it into another agent that reads SKILL.md.

1

Install in TypingMind

TypingMind installs a skill straight from its GitHub folder — it reads SKILL.md, bundles the resource files, and stores the result locally.

  1. Open the app and go to Plugins → Skills.
  2. Choose "Install from GitHub".
  3. Paste the skill folder URL below and confirm.
  4. Enable the skill in any chat where you want it available.
Plugins → Skills → Add skill → From GitHub URL, then paste the folder URL and press Continue.
2

Install in another agent

Any agent that reads the Agent Skills format can use this skill — copy the folder into that agent's skills directory.

Claude Code — .claude/skills
git clone --depth 1 https://github.com/xu-xiang/everything-claude-code-zh.git /tmp/everything-claude-code-zh
mkdir -p .claude/skills
cp -r /tmp/everything-claude-code-zh/docs/ja-JP/skills/springboot-security .claude/skills/springboot-security
Restart Claude Code after copying so it picks up the new skill.

Use it in TypingMind

Enable Springboot Security in any TypingMind chat and the model takes it from there. Its name and description sit in the system prompt, and the moment a request matches, the model loads the full instructions itself — you never invoke it by hand, and it costs no tokens until it is actually used.

The model loads Springboot Security on its own as soon as a request matches it.

Works with any AI model

AI skills are plain Markdown instructions rather than provider-specific code, so Springboot Security is not tied to the model it was written for. Install it once in TypingMind and use it with GPT-5, Claude, Gemini, Grok, DeepSeek, Mistral, Llama, or a local model you run yourself — all on your own API keys.

  • Loaded only when it is needed

    The system prompt carries just the name and description. The instructions are fetched on the first matching request, so an idle skill costs nothing.

  • Switch models mid-chat

    Because the skill is instructions rather than code, changing model does not break it — the next model reads the same SKILL.md.

Skill instructions

This is the SKILL.md content the model loads. Read it before installing — a skill is instructions your model will follow.

Spring Boot 安全审查

在添加身份验证、处理输入、创建端点或处理敏感密钥时使用。

身份验证(Authentication)

  • 优先使用无状态 JWT 或带有吊销列表的不透明令牌(Opaque Token)
  • 对于会话,使用 httpOnlySecureSameSite=Strict 的 Cookie
  • OncePerRequestFilter 或资源服务器中验证令牌
java
@Component
public class JwtAuthFilter extends OncePerRequestFilter {
  private final JwtService jwtService;

  public JwtAuthFilter(JwtService jwtService) {
    this.jwtService = jwtService;
  }

  @Override
  protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response,
      FilterChain chain) throws ServletException, IOException {
    String header = request.getHeader(HttpHeaders.AUTHORIZATION);
    if (header != null && header.startsWith("Bearer ")) {
      String token = header.substring(7);
      Authentication auth = jwtService.authenticate(token);
      SecurityContextHolder.getContext().setAuthentication(auth);
    }
    chain.doFilter(request, response);
  }
}

授权(Authorization)

  • 启用方法级安全:@EnableMethodSecurity
  • 使用 @PreAuthorize("hasRole('ADMIN')")@PreAuthorize("@authz.canEdit(#id)")
  • 默认拒绝访问,仅公开必要的范围(Scope)

输入验证(Input Validation)

  • 在控制器中使用 @Valid 进行 Bean Validation
  • 在 DTO 上应用约束:@NotBlank@Email@Size 以及自定义校验器
  • 在渲染前使用白名单对 HTML 进行清理(Sanitize)

SQL 注入防护

  • 使用 Spring Data Repository 或参数化查询
  • 原生查询使用 :param 绑定,禁止字符串拼接

CSRF 防护

  • 对于浏览器会话应用,启用 CSRF 并在表单/响应头中包含令牌
  • 对于使用 Bearer 令牌的纯 API 应用,禁用 CSRF 并依赖无状态身份验证
java
http
  .csrf(csrf -> csrf.disable())
  .sessionManagement(sm -> sm.sessionCreationPolicy(SessionCreationPolicy.STATELESS));

密钥管理(Secrets Management)

  • 禁止在源码中包含密钥。从环境变量或 Vault 加载
  • 确保 application.yml 中不含凭据,使用占位符代替
  • 定期轮换令牌和数据库凭证

安全响应头(Security Headers)

java
http
  .headers(headers -> headers
    .contentSecurityPolicy(csp -> csp
      .policyDirectives("default-src 'self'"))
    .frameOptions(HeadersConfigurer.FrameOptionsConfig::sameOrigin)
    .xssProtection(Customizer.withDefaults())
    .referrerPolicy(rp -> rp.policy(ReferrerPolicyHeaderWriter.ReferrerPolicy.NO_REFERRER)));

速率限制(Rate Limiting)

  • 对高成本端点应用 Bucket4j 或网关级限制
  • 记录突发流量日志并发送告警,返回带有重试提示的 429 状态码

依赖项安全(Dependency Security)

  • 在 CI 中运行 OWASP Dependency Check / Snyk
  • 保持 Spring Boot 和 Spring Security 处于受支持的版本
  • 针对已知的 CVE 漏洞使构建失败

日志与 PII(个人识别信息)

  • 禁止在日志中记录密钥、令牌、密码或完整的银行卡号(PAN)数据
  • 脱敏敏感字段,并使用结构化 JSON 日志

文件上传

  • 验证文件大小、内容类型(Content-Type)和扩展名
  • 存储在 Web 根目录之外,并根据需要进行扫描

发布前检查清单

  • 身份验证令牌已正确验证且未过期
  • 所有敏感路径都有授权保护(Authorization Guard)
  • 所有输入已验证并清理
  • 没有通过字符串拼接的 SQL 语句
  • 针对应用类型采用了正确的 CSRF 对策
  • 密钥已外部化,未提交至仓库
  • 已配置安全响应头
  • API 设有速率限制
  • 依赖项已扫描且为最新版本
  • 日志中不含敏感数据

注意:默认拒绝(Default Deny)、验证输入、应用最小权限原则,并优先采用“配置即安全”的实践。

Frequently asked questions

What does the Springboot Security AI skill do?

Spring Boot 服务的 Spring Security 身份验证/授权、验证、CSRF、密钥、响应头、速率限制和依赖项安全最佳实践。

Why use Springboot Security on TypingMind?

Because you install it once and use it with any model. Springboot Security is plain Markdown rather than provider-specific code, so the same skill runs on GPT-5, Claude, Gemini, Grok, or a local model — and you can switch model mid-chat without it breaking. TypingMind runs on your own API keys, so you pay providers directly instead of a per-seat subscription, and your skills and chats stay in your own storage.

How do I install Springboot Security in TypingMind?

Open Plugins → Skills → Install from GitHub in TypingMind and paste https://github.com/xu-xiang/everything-claude-code-zh/tree/main/docs/ja-JP/skills/springboot-security. TypingMind reads its SKILL.md and installs it as a skill you can enable per chat.

Which AI models can use Springboot Security?

Any model you connect in TypingMind. AI skills are plain Markdown instructions rather than provider-specific code, so GPT, Claude, Gemini, Grok, and local models can all load this skill when a request matches it.

How many AI models can I use with Springboot Security?

As many as you like. As long as a model supports skills, you can use Springboot Security with it — GPT, Claude, Gemini, Grok, DeepSeek, Mistral, Llama and more — all on TypingMind with your own API keys.

Is the Springboot Security AI skill free?

Yes. It is published on GitHub by xu-xiang under the MIT license. You only pay your own AI provider for the tokens you use.

What are AI skills?

An AI skill is a reusable instruction bundle that teaches an AI model how to do one specific task. It follows the open Agent Skills format: a SKILL.md file with a name and description, plus any scripts, templates or reference files the model may need. The model reads the instructions only when your request matches the skill, so an installed skill costs nothing until it is used.

How are AI skills different from plugins or MCP servers?

A plugin or MCP server gives a model new tools to call — code that runs somewhere and returns a result. An AI skill gives the model knowledge and process instead: how to approach a task, which steps to follow, what good output looks like. Skills are plain Markdown, so they need no server, no API key and no runtime, and they work with any model.

View all

Set up your own AI workspace now

Get notified about new features and future giveaways by subscribing to our newsletter 👇